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