Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I'm making a spectate GUI and its not working?

Asked by 5 years ago

So i'm making a spectate GUI, as the title states, but i'm having trouble changing the local current camera, how would i fix this?

1target = script.Parent.Parent.TextBox.target.Value
2 
3 
4script.Parent.MouseButton1Click:Connect(function()
5    game.Workspace.Camera.CameraSubject = target
6end)

Thanks,

0
What is this value that you defined as target? Nanomatics 1160 — 5y
0
its the target part/player EllaTheFloofyFox 106 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

I would recommend making the target value the player of the character you wish to spectate. If this is what you are doing then copy below and paste.

01local camera  = workspace.CurrentCamera
02local target = script.Parent.Parent.TextBox.target
03 
04script.Parent.MouseButton1Click:Connect(function()
05    local char = target.Value.Character or workspace:FindFirstChild(target.Value.Name)
06    if not char then return end
07    local humanoid = char:FindFirstChildOfClass("Humanoid")
08    if not humanoid then return end
09    camera.CameraSubject = humanoid
10end)
Ad

Answer this question