Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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,

2 comments

0

What is this value that you defined as target?

0

its the target part/player

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.