So, I'm trying to change a player's health using a gui button ; If they have enough coins. Scripts:
--Local Script--
local button = script.Parent.Button
button.MouseButton1Click:Connect(function()
if plr.leaderstats.Coins.Value >= button.Coins.Value then
folder.ChangeHealth:FireServer(20,30) -- 20 is hp, 30 is the coin value
end
end)
--Server Script--
game.ReplicatedStorage.Gui.Menu.ChangeHealth.OnServerEvent:Connect(function(plr,hp,m)
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - m
local ch = plr.Character
ch.Humanoid.MaxHealth = ch.Humanoid.MaxHealth + hp
end)
After i typed this, and tested it, my coin value goes to a negative number. Why?
