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

Can someone explain to me what I would do for a spectate tool?

So I want it so when I open up the tool I view a PART not a person then when I click I view a different part (only 2 parts total) and I have no idea what I'm doing? Dont do it for me but I legit have 0 ideas of what im changing.

1 comment

0

Maybe change the CurrentCamera.Subject to the mouse.Target on mouse.Button1Down

1 answer

✓ Accepted answer

Here's a quick example I made of this working:

local cam = workspace.CurrentCamera -- defining the player's camera

local Parts = {workspace.Part1, workspace.Part2} -- table with the parts we want to switch between
local cycle = 1 -- a useful variable to cycle index the Parts table

-- I just used a loop as a demonstration.
while wait(1) do
	cam.CameraSubject = Parts[cycle] -- We're changing the camera to look at a Part within the Parts table
	cycle = cycle + 1
	if cycle > #Parts then
		cycle = 1
	end
-- ^ Simple cycle between the parts, if we go over Part's max index then this will change the cycle variable back to 1 to prevent errors (indexing a value that isn't there)
end

All the best.

3 comments

0

Note that this has to be a local script, within a runable local script area and you might want to consider doing stuff like workspace:WaitForChild("Part1") on your parts because they might not exist to the client when we try to find them. If you need anymore information then feel free to leave a comment.

0

Thanks!!!!

0

Welcome.

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