2

# LockFirstPerson - How do i correctly do it?

I have this script, that's inside of a button.

function onClicked()
script.Parent.Parent.Parent:remove()
print("everything removed")
game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
print("FirstPersonisLocked")
end

script.Parent.MouseButton1Click:connect(onClicked)


When i test it out in Play Solo, it works fine. But in a server, it doesn't go to first person. It just closes out the Gui. (The first part of the script.)

Why does it do this? Can someone tell me a correct way to do it?

script.Parent.MouseButton1Click:connect(function() -- Improved with anonymous function