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

nothing happens when brick is clicked?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

0
ah, i see what you mean, now im back to the problem where the else isnt working thenormalelevator32 26 — 4y
0
Is the money value a number value? maumaumaumaumaumua 628 — 4y
0
Does it at least destroy the part? maumaumaumaumaumua 628 — 4y
0
money value is a int value, it prints not enough money when clicked with enough money thenormalelevator32 26 — 4y
View all comments (7 more)
0
Can you show an image of the value in explorer and output ? maumaumaumaumaumua 628 — 4y
0
https://imgur.com/a/sJeFGpB is that what you mean? thenormalelevator32 26 — 4y
0
Is the money value set locally? If it is set it server-side maumaumaumaumaumua 628 — 4y
0
i set it globally (what i think you saying) still nothing thenormalelevator32 26 — 4y
0
Try printing the value on clicking maumaumaumaumaumua 628 — 4y
0
its always printing 0 thenormalelevator32 26 — 4y
0
You should set it from the server and not client maumaumaumaumaumua 628 — 4y
Ad

Answer this question