Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 5 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)

0
Please state the output. Articulating 1320 — 5y
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 iipartyhat 25 — 5y

### 1 answer

Log in to vote
2
Answered by 5 years ago
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)

0
i worked for the 1st click but the rest it just went up by 6 D: iipartyhat 25 — 5y
0
nvm it works! thx iipartyhat 25 — 5y