Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What do I do? Whenever a player respawns, the value wont keep it to true

When a player resets, the value of "hasPassed" (If a player has passed the simple laser obby) used to be true before they died but now, it just keeps it at false.

How do I keep it at true forever, even if they die?

Script (Type: Normal Script, not local or module, Parent: workspace.Detector):

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)

	if player then
		if hit.Parent:FindFirstChild("Humanoid") then
			local hasPassed = player.Character.SprintScript.HasPassed
			
			if hasPassed then
				hasPassed.Value = true
			end
		end
	end
end)

Script Explanation:

When a player touched a brick called "Detector", it uses a variable called "player" and it gets the player by getting player from it's character and if the player exists & it has a humanoid then, it also uses a variable called "hasPassed" which is from the player's character and if the boolean value does exist, then the value is true.

2 answers

✓ Accepted answer

I recommend you to place the value to Player and not to Character. Because everytime Character get Loaded, It will reset everything inside it!

To Put Value inside of the Player, You can use this Script:

Players.PlayerAdded:Connect(function(Player)
	local Folder = Instance.new("Folder",Player)
        Folder.Name = "Put Folder Name Here"
        
        local Value = Instance.new("BoolValue",Folder)
        Value.Name = "Put Value Name Here"
end)

Hope It Helps!

while loops always do the trick

while true do
      hasPassed.Value = true
      wait(0.00001)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.