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

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

Asked by 8 years ago

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.

0
Maybe change the CurrentCamera.Subject to the mouse.Target on mouse.Button1Down ScriptsAhoy 202 — 8y

1 answer

Log in to vote
1
Answered by
0_0 70
8 years ago

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.

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_0 70 — 8y
0
Thanks!!!! iSidersz 70 — 8y
0
Welcome. 0_0 70 — 8y
Ad

Answer this question