Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local UIS = game:GetService("UserInputService")
- local RenderStep = game:GetService("RunService").RenderStepped
- local ZoomButton = Player.PlayerGui:WaitForChild("GamePanel").Frame.ZoomButton
- local Teams = {["Blue"] = 60, ["Green"] = 120, ["Pink"] = 180, ["Purple"] = 240, ["Red"] = 300, ["Yellow"] = 360}
- local Tiles = workspace.Tiles
- local Mouse = Player:GetMouse()
- local Camera = workspace.CurrentCamera
- local CameraParts = workspace.CameraParts
- local CameraPart = CameraParts.CameraPart
- local Pivot = CameraParts.Pivot
- local P0 = CameraParts.P0
- local P1 = CameraParts.P1
- local P2 = CameraParts.P2
- local W,S,A,D,Q,E = false,false,false,false,false,false
- local ControlsEnabled, Zooming = true, true
- local Rotation = Teams[Player.Team.Name] + 180
- local Width = Tiles.Width
- local CentrePosition = 0
- local ZoomAmount = 0
- local X,Y,Z = 0,0,0
- local Index = 1
- local IndexAmount = 0.5
- local TotalZoom = 0
- local MinZoom = 10
- local Scroll = 0
- local Step = 40
- local Zoom = 0
- local MaxZoom = (Width.Value*51.96)/4
- local MoveSpeed = Width.Value/4 * 10
- local MaxIndex = Width.Value
- local ZoomSpeed = 5
- Camera.CameraType = Enum.CameraType.Scriptable
- P0.Orientation += Vector3.new(0,Rotation,0)
- Pivot.Orientation = Vector3.new(-80, Rotation, 0)
- for i,v in Tiles:GetChildren() do
- if v:FindFirstChild("CornerMarker") then
- if v.CornerMarker.Value == Player.Team.Name then
- P0.Position = v.Position + Vector3.new(0,1.5,0)
- end
- end
- if v:FindFirstChild("CentreMarker") then
- CentrePosition = v.Position
- end
- end
- Mouse.WheelForward:Connect(function()
- Scroll = -Step
- end)
- Mouse.WheelBackward:Connect(function()
- Scroll = Step
- end)
- ZoomButton.Activated:Connect(function()
- if ZoomButton.Text == "Show full map" and not Zooming then
- ZoomButton.Active = false
- ControlsEnabled = false
- Zooming = true
- elseif ZoomButton.Text == "Zoom in" and not Zooming then
- ZoomButton.Active = false
- Zooming = true
- end
- end)
- UIS.InputBegan:Connect(function(input, gpe)
- if gpe then return end
- if input.KeyCode == Enum.KeyCode.W then
- Z = MoveSpeed
- W = true
- end
- if input.KeyCode == Enum.KeyCode.S then
- Z = -MoveSpeed
- S = true
- end
- if input.KeyCode == Enum.KeyCode.A then
- X = MoveSpeed
- A = true
- end
- if input.KeyCode == Enum.KeyCode.D then
- X = -MoveSpeed
- D = true
- end
- if input.KeyCode == Enum.KeyCode.Q then
- Y = -ZoomSpeed
- Q = true
- end
- if input.KeyCode == Enum.KeyCode.E then
- Y = ZoomSpeed
- E = true
- end
- end)
- UIS.InputEnded:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.W then
- W = false
- end
- if input.KeyCode == Enum.KeyCode.S then
- S = false
- end
- if input.KeyCode == Enum.KeyCode.A then
- A = false
- end
- if input.KeyCode == Enum.KeyCode.D then
- D = false
- end
- if input.KeyCode == Enum.KeyCode.Q then
- Q = false
- end
- if input.KeyCode == Enum.KeyCode.E then
- E = false
- end
- end)
- RenderStep:Connect(function()
- if ControlsEnabled then
- if not W and not S and Z > 0 then
- Z -= MoveSpeed/10
- end
- if not W and not S and Z < 0 then
- Z += MoveSpeed/10
- end
- if not A and not D and X > 0 then
- X -= MoveSpeed/10
- end
- if not A and not D and X < 0 then
- X += MoveSpeed/10
- end
- if not Q and not E and Y > 0 then
- Y -= ZoomSpeed/10
- end
- if not E and not Q and Y < 0 then
- Y += ZoomSpeed/10
- end
- if Scroll > 0 then
- Scroll -= Step/10
- end
- if Scroll < 0 then
- Scroll += Step/10
- end
- Zoom += Scroll/10 + Y
- Zoom = math.clamp(Zoom, MinZoom, MaxZoom)
- P0.Position += P0.CFrame.RightVector * X/10 + P0.CFrame.LookVector * -Z/10
- Pivot.Position = P0.Position + Vector3.new(0,10,0)
- CameraPart.Position = Pivot.Position -Pivot.CFrame.LookVector * Zoom
- CameraPart.CFrame = CFrame.lookAt(CameraPart.Position, Pivot.Position)
- Camera.CFrame = CameraPart.CFrame
- elseif Zooming then -- if not ControlsEnabled aka ZoomButton was pressed
- if ZoomButton.Text == "Show full map" then
- local Lerp1 = P0.Position:Lerp(P1.Position, Index/MaxIndex)
- local Lerp2 = P1.Position:Lerp(P2.Position, Index/MaxIndex)
- local Bezier = Lerp1:Lerp(Lerp2, Index/MaxIndex)
- if Index < MaxIndex - IndexAmount then
- Index += IndexAmount
- else
- ZoomButton.Text = "Zoom in"
- ZoomButton.Active = true
- Zooming = false
- end
- -- Move and angle Pivot
- Pivot.CFrame = CFrame.new(Bezier)
- Pivot.Orientation = Vector3.new(-65-(25*Index/MaxIndex), Rotation+180, 0)
- --Offset camera from Pivot and make it look at Pivot
- Camera.CFrame = CFrame.new(Pivot.Position + Pivot.CFrame.LookVector*-TotalZoom)
- Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, Pivot.Position)
- else
- local Lerp1 = P0.Position:Lerp(P1.Position, Index/MaxIndex)
- local Lerp2 = P1.Position:Lerp(P2.Position, Index/MaxIndex)
- local Bezier = Lerp1:Lerp(Lerp2, Index/MaxIndex)
- if Index > 1 then
- Index -= IndexAmount
- else
- ZoomButton.Text = "Show full map"
- ZoomButton.Active = true
- ControlsEnabled = true
- Zooming = false
- end
- -- Move and angle Pivot
- Pivot.CFrame = CFrame.new(Bezier)
- Pivot.Orientation = Vector3.new(-65-(25*Index/MaxIndex), Rotation*60+180, 0)
- --Offset camera from Pivot and make it face Pivot
- Camera.CFrame = CFrame.new(Pivot.Position + Pivot.CFrame.LookVector*-TotalZoom)
- Camera.CFrame = CFrame.lookAt(Camera.CFrame.Position, Pivot.Position)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement