Hello! I’m just trying out some things with scripting, as I’m fairly new to it. I tried making a button that, when clicked, would take away some of the player’s currency. However, I keep getting this error in the output:
The currency is an IntValue named “Tickets”, and is located directly inside of the player. I’m using a server script, which is located inside of a TextButton. Here’s the code that’s causing the error:
script.Parent.MouseButton1Down:Connect(function(player)
local tickets = player.Tickets
if tickets.Value >= 125 then
tickets.Value = tickets.Value - 125
end
end)
MouseButton1Click’s arguments are where the player clicked, not a player. (cjjdawg’s solution is right, this is just to clarify why the error is what it is.)
And also, if you’re using a TextButton as the button to click, you’d want to use “MouseButton1Click:Connect” instead of “MouseButton1Down:Connect” I believe.
Also, the reason why I used a server script was because I needed to get other objects that couldn’t be accessed with a LocalScript. The RemoteEvent idea that @cjjdawg mentioned solved it.