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

Leaderstat Value Won't Change?

I made this script which waits 60 seconds, then increases a leaderstat value by 1. But for some reason nothing happens to the value, and I don't get any errors on it. I feel like the answer is obvious but I have no idea how to fix it. Here's the code:

wait(1.5)
function Min(NP)
	while true do
		local Stat = NP.leaderstats["Minutes Played"].Value
		wait(60)
		Stat = Stat + 1
	end
end


game.Players.ChildAdded:Connect(Min)

I've also tried making it a StarterPlayerScripts script and the same thing happens, code below.

wait(2)
while true do
	wait(6)
	script.Parent.Parent.leaderstats["Minutes Played"].Value = 
        script.Parent.Parent.leaderstats["Minutes Played"].Value +1
end

1 comment

0

Local Scripts only change to Local Player... you should use a normal script

1 answer

✓ Accepted answer

Problem with the 1st script: You used a child added function and therefore it waits 60 seconds everytime a child is added to players. You need to find the value from the player in a different way, by using remote events, local script and a script.

Problem with the 2nd script: Most likely you did this in a local script, so you cannot change the value. Therefore use a remote event and a server script to change the value.

Hope this helps, if not feel free to ask questions.

1 comment

0

Ah ok. I did use a normal script for the 2nd one but no remote event. Thanks.

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