Hello. I have this sort of intro script. It fixes the camera and rotates it, with a GUI and TextButtons.
Anyway, I want this script to only run once, when the player first joins. Currently, it runs when the player joins AND when the player respawns.
It doesn't need to use PlayerAdded. I just thought that'd be the best way to do it. I've already attempted it with no results.
local camera = game.Workspace.CurrentCamera
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local camPart = game.Workspace.camPart
local playClicked = false
repeat wait() until plr.Character
camPart.Transparency = 1
camera.CameraType = "Scriptable"
camera.CFrame = game.Workspace.camPart.CFrame
-- I spawn this function so the while loop can execute while the rest of the code does as well.
spawn(function()
while true do
if playClicked then break end
camera.CFrame = camera.CFrame * CFrame.Angles(0,0.005,0)
wait()
end
end)
-- Takes control from the player and enables the GUI.
script.Parent.Enabled = true
plr.Character.Humanoid.JumpPower = 0
plr.Character.Humanoid.WalkSpeed = 0
-- We need to de-activate the GUI, restore default camera, break the while loop, and restore player controls.
script.Parent.play.MouseButton1Click:Connect(function()
script.Parent.Enabled = false
camera.CameraType = "Custom"
playClicked = true
plr.Character.Humanoid.JumpPower = 50
plr.Character.Humanoid.WalkSpeed = 16
end)

3 comments
Where is this script located? SPS, StarterGui etc?
It's a LocalScript inside of a ScreenGUI.
Okay so, if you only want it to run once, you can either handle this from StarterPlayerScripts, or you can disable the ResetOnSpawn property of your ScreenGui provided it doesn't break it. I always handle my UI from StarterPlayerScripts.