Trying to lock player in first person from third person after clicking a button. I am using a RemoteEvent in ReplicatedStorage called FirstPersonEvent to do this, but scripts don't seem to be working and I can't find where issue is. Here is script located in the button (called ButtonTrigger):
function onClicked()
local ButtonTrigger = script.Parent
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local FirstPersonEvent = ReplicatedStorage:WaitForChild('FirstPersonEvent')
ButtonTrigger.Clicked:Connect(function(onClicked)
local player = game:GetService('Players'):GetPlayerFromCharacter(onClicked.Parent)
if player then
FirstPersonEvent:FireClient(player)
end
end)
end
game.Workspace.ButtonTrigger.ClickDetector.MouseClick:connect(onClicked)
LocalScript located inside of StarterCharacterScripts:
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local FirstPersonEvent = ReplicatedStorage:WaitForChild('FirstPersonEvent')
local function onFirstPerson()
local player = game.Players.LocalPlayer
player = game.Players.LocalPlayer
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
FirstPersonEvent.OnClientEvent:Connect(onFirstPerson)
Sorry if this is complete mess, still learning. Thanks for reading
