Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question