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

Spectate Script Help Broken?(SOLVED) [closed]

Asked by 10 years ago

How do I make a spectator tool to view different players? I have no idea how to do this. This is my attempt:

function onSelected(tool)
game.Players.LocalPlayer
function Camera = "Spectate"
Camera.Position.Vector3.new(0,0,0)
end
end
end

This is what I tried. It didn't work. Someone please help me fix it so it will let players spectate other players.

0
What are you trying to do with the 'game.Players.LocalPlayer' line? It seems to be strange. gskw 1046 — 10y
0
I have no knowledge using Camera commands. I tried my best :c MUSHR0OM 0 — 10y

Locked by Shawnyg and AmericanStripes

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 10 years ago

What does that mean? You can't create a variable "function" and assign to it a string value, that absolutely make sense, if you want to do something with enums, I suggest you to create a Script that stores camera's enums like this:

local enums { "Spectate", "First Person", "Third Person" }

_G.storeEnums = function(par1)
    for _, v in pairs (par1) do
        if not game.YourPathStorage:FindFirstChild(v) then
            local par2 = Instance.new("StringValue", game.YourPathStorage)
            par2.Name = v
            if v == "First Person" then
                par2.Value = true -- the camera initialized is First Person
            end
        end
    end
end

Call that function where you want, I suggest you on ServerStart.

And then create a getter function (if you want) for fast access, from that you call what type of enum you need for your camera:

function getActivatedEnum()
    local enums = game.YourPathStorage:GetChildren()
    for _, v in pairs (enums) do
        if game.YourPathStorage:FindFirstChild(v).Value == true then
            return v -- return the activated enum
        end
    end
end

function setActivatedEnum(par1)
    local enums = game.YourPathStorage:GetChildren()
    local par2 = game.YourPathStorage:FindFirstChild(par1)
    for _, v in pairs (enums) do
        local par3 = game.YourPathStorage:FindFirstChild(v)
        par3.Value = false
    end
    par2.Value = true -- activate the enum in passed as the argument "par1"
end

function changeCamera()
    local camera = getActivatedEnum()
    if camera== "First Person" then -- if the camera name is 'First Person'....
        setActivatedEnum("Spectate") -- disable all of the enums except the requested on, in this case it's "Spectate"
    end
end

That's an advanced Enum System by me, it works because I use it :P

0
How would I use this, so that when the player(s) are in the lobby, they can use this. And not during the game? MUSHR0OM 0 — 10y
0
Just load it on "PlayerAdded" ._. alessandro112 161 — 10y
Ad