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

Why won't the player go back down to 0 Money from an OnTouch script?

I'm trying to make a reset block so when the player touches this part, their leaderstats will restart. But it doesn't work.

function onTouched(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		player.leaderstats.Cash.Value = 0
	end
end

1 answer

✓ Accepted answer

You forgot to add a "Touched Event" onto your script. This should work:


function onTouched(hit)
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if player then
        player.leaderstats.Cash.Value = 0
    end
end
script.Parent.Touched:Connect(onTouched)

Hope this helps, LennyPlayzYT

1 comment

0

Yes It works!

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