Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local plr = Players.LocalPlayer
- local camera = workspace.CurrentCamera
- local index = 1
- function setIndex(change)
- local list = Players:GetPlayers()
- if((index+change) < 1) then
- index = #list
- elseif((index+change) > #list) then
- index = 1
- else
- index = index+change
- end
- local target = list[index]
- local char = target.Character or target.CharacterAdded:Wait()
- local hum = char:WaitForChild("Humanoid")
- camera.CameraSubject = char
- script.Parent.PlayerName.Text = target.Name
- end
- script.Parent.Parent.Spectate.InputBegan:Connect(function(input)
- if(input.UserInputType == Enum.UserInputType.MouseButton1) then
- local char = plr.Character or plr.CharacterAdded:Wait()
- local hum = char:WaitForChild("Humanoid")
- if(script.Parent.Position ~= UDim2.new(0.338, 0,0.792,0)) then
- script.Parent:TweenPosition(UDim2.new(0.338, 0,0.792,0))
- script.Parent.PlayerName.Text = plr.Name
- hum.WalkSpeed = 0 --Disable player movement
- else
- script.Parent:TweenPosition(UDim2.new(0.338, 0, 1.2, 0))
- camera.CameraSubject = hum
- hum.WalkSpeed = 16
- end
- end
- end)
- script.Parent.Forward.InputBegan:Connect(function(input)
- if(input.UserInputType == Enum.UserInputType.MouseButton1) then
- setIndex(1)
- end
- end)
- script.Parent.Backward.InputBegan:Connect(function(input)
- if(input.UserInputType == Enum.UserInputType.MouseButton1) then
- setIndex(-1)
- end
- end)
- --I am honestly not sure whether to use InputBegan or Activated, I just used InputBegan for now.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement