I'm making a game with a script THAT CHANGES THE PLAYERS SCORE EVERY SECOND, AND RESETS BACK TO ZERO WHEN THE PLAYER DIES. This works fine. However, I need the timer to only start when the player isn't touching a certain part (Called "StartPart"). I still need to keep the same aspects of the script I meantioned aboye (In CAPITALS). Heres the script I have currently:
local Players = game:GetService("Players") local UpdatePoints = false Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) UpdatePoints = true local Leaderstats = Instance.new("Folder") Leaderstats.Name = "leaderstats" Leaderstats.Parent = Player local Points = Instance.new("IntValue") Points.Name = "Points" Points.Parent = Leaderstats Player.leaderstats.Points.Value = 0 local Humanoid = Character.Humanoid Humanoid.Died:Connect(function() UpdatePoints = false Player.leaderstats.Points.Value = 0 end) while (UpdatePoints) do wait(1) Player.leaderstats.Points.Value += 1 if not (UpdatePoints) then break end end end) end)