So, this I tested this in a local script, and a server script (default script), and none of them are working. This script was originally designed to work to the extent where when a player clicks the gui button, it teleports them, makes the gui non-visible, and locks the players screen in first person.
However, it isn't working. Help?
local Button = script.Parent Frame = script.Parent.Parent.gggg function onClick() game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43) wait() game.Players.LocalPlayer.Character.Torso.Anchored=true wait() Frame.Visible = false end Button.MouseButton1Click:connect(onClick)
Here is your final script:
local Button = script.Parent Frame = script.Parent.Parent function onClick() game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43) wait() game.Players.LocalPlayer.Character.Torso.Anchored=true wait() game.Players.LocalPlayer.CameraMode = "LockFirstPerson" Frame.Visible = false end Button.MouseButton1Click:connect(onClick)
Awesome, thanks guys I got it to function properly! Now I'm just experiencing one more tiny problem. First person isn't locking when the button is clicked.
local Button = script.Parent Frame = script.Parent.Parent function onClick() game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43) wait() game.Players.LocalPlayer.Character.Torso.Anchored=true wait() Frame.Visible = false script.Parent.Parent.CameraMode="LockFirstPerson" end Button.MouseButton1Click:connect(onClick)
I have script.Parent.Parent.CameraMode="LockFirstPerson"
which should be correct, this script is local and it's in StarterGui.