I am trying to create a chat command (one you can type in-game and activate the function) to either lock someone in first person or allow them to zoom out once again. My problem is getting the command to send it to the players. So far I have this in the localscript:
function game.Workspace.OnClientInvoke(FirstPerson)
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end
function game.Workspace.OnClientInvoke(ThirdPerson)
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
end
And this in the Server Script:
function onCommand(message, player)
if message:sub(1, 12) == ":firstperson" and TrueAdmin[player.Name] then
local CameraMode = Instance.new("Camera Mode")
CameraMode.Parent = game.Workspace
CameraMode.Name = "First Person"
function CameraMode(player)
local success, result = pcall(function() return CameraMode:InvokeClient(player) end)
if success then
print(result)
else
print("Not able to change Camera Mode")
end
end
end
if message:sub(1, 12) == ":thirdperson" and TrueAdmin[player.Name] then
local CameraMode = Instance.new("Camera Mode")
CameraMode.Parent = game.Workspace
CameraMode.Name = "First Person"
function CameraMode(player)
local success, result = pcall(function() return CameraMode:InvokeClient(player) end)
if success then
print(result)
else
print("Not able to change Camera Mode")
end
end
end
end
-- Chat commands are working. I have already got that and these are in a function.
EDIT: Edited on mobile. So pardon the missed tabs.
Thanks a lot for helping me out. I realize that I may have been asking quite a few questions, but thank you so much.

2 comments
Do you mean my localscript, or my regular script?
You said your localscript was in ServerStorage.