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

Why isn't this working? (It's a short script)

amount = math.random(3, 7)

script.Parent.ClickDetector.MouseClick:connect(function(pl)

local ls = pl:findFirstChild("leaderstats") local g = ls:findFirstChild("Gold")

g.Value = g.Value + amount

end)

2 comments

0

Please state the output.

0

there's no error in the out put, when i click the brick it just adds 7 to my gold stats it doesnt randomize it like i want it to

1 answer

✓ Accepted answer

math.randomseed(tick())
script.Parent.ClickDetector.MouseClick:connect(function(pl)
    local amount = math.random(3, 7)
    local ls = pl:findFirstChild("leaderstats") 
    local g = ls:findFirstChild("Gold")
    g.Value = g.Value + amount
end)

2 comments

0

i worked for the 1st click but the rest it just went up by 6 D:

0

nvm it works! thx

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