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

How can I make it so when a block is touched it changes a stat?

I saw this on here a while ago


Brick = script.Parent Brick.Touched:connect(function() Player.leaderstats.Retrives.Value = Player.leaderstats.Retrives.Value + 1 end)


It no longer seems to work. Can someone please help.

1 answer

✓ Accepted answer

Player wasn't defined, try this instead:

local Brick = script.Parent
Brick.Touched:connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if Player then 
		Player.leaderstats.Retrives.Value = Player.leaderstats.Retrives.Value + 1
	end
end)

and make sure you have something called "leaderstats" in your player, "Retrives" in leaderstats, and the script in your brick.

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