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

nothing happens when brick is clicked?

basically the parent clones into workspace and clicking it should buy it

game.Players.PlayerAdded:Connect(function(plr)
Money = plr.leaderstats.Money
script.Parent.ClickDetector.MouseClick:Connect(function()
if Money.Value < 30 then
    print('not enough money')
else
Money.Value = Money.Value - 30
script.Parent:Destroy()
end
end)
end)

1 answer

✓ Accepted answer

You're doing something wrong, other people can click the brick and use your OWN money, so instead of doing that you just add a single event.



script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if not plr then return end -- End the function if there's no player

Money = plr.leaderstats.Money
if Money.Value < 30 then
    print('not enough money')
else
Money.Value = Money.Value - 30
script.Parent:Destroy()
end

end)

Done! Now you listen with one connection instead of more, and now it only does it to the player that clicked it! If this helped mark this as the answer!

11 comments

0

ah, i see what you mean, now im back to the problem where the else isnt working

0

Is the money value a number value?

0

Does it at least destroy the part?

0

money value is a int value, it prints not enough money when clicked with enough money

0

Can you show an image of the value in explorer and output ?

0

https://imgur.com/a/sJeFGpB is that what you mean?

0

Is the money value set locally? If it is set it server-side

0

i set it globally (what i think you saying) still nothing

0

Try printing the value on clicking

0

its always printing 0

0

You should set it from the server and not client

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