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 4 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?

target = script.Parent.Parent.TextBox.target.Value


script.Parent.MouseButton1Click:Connect(function()
    game.Workspace.Camera.CameraSubject = target
end)

Thanks,

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

1 answer

Log in to vote
1
Answered by 4 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.

local camera  = workspace.CurrentCamera
local target = script.Parent.Parent.TextBox.target

script.Parent.MouseButton1Click:Connect(function()
    local char = target.Value.Character or workspace:FindFirstChild(target.Value.Name)
    if not char then return end 
    local humanoid = char:FindFirstChildOfClass("Humanoid")
    if not humanoid then return end 
    camera.CameraSubject = humanoid
end)
Ad

Answer this question