players.PlayerAdded:Connect(function(player)
local button = script.Parent
local statpoints = player.leaderstats.StatPoints
local defense = player.leaderstats.Defense
local function leftClick()
if statpoints.Value >= 1 then
statpoints.Value -= 1
defense.Value += 1
end
end
button.MouseButton1Click:Connect(leftClick)
end)
1 Like
I would recommend using a remote event to send a signal to the server from a local script inside of the button when the button is clicked to change the value as this may work better.
You may find this useful:
Remote Event Documention
1 Like
If your confused by this just create a Remote Event in replicated storage and call it when the player clicks.
IIRC Button clicks aren’t recorded by the server, so it makes sense why it’s not getting detected. You need a separate script placed in the client’s button GUI to detect that, then send that action through a remote event and handle the logic from there.
lol whoops i didnt realize someone said that before me