✓ Accepted answer
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
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
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
end
function changeCamera()
local camera = getActivatedEnum()
if camera== "First Person" then
setActivatedEnum("Spectate")
end
end
That's an advanced Enum System by me, it works because I use it :P
2 comments
What are you trying to do with the 'game.Players.LocalPlayer' line? It seems to be strange.
I have no knowledge using Camera commands. I tried my best :c