Hey,
So I’m making a health button, when you click, you have more health.
So for that, I use a Remote Event, when you click to a button, a Remote Event is activate and the event is recieve.
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if plr.Settings.Medicine.Value > 0 then
game.ReplicatedStorage.BuyButtonValue:FireServer()
end
end)
I also have a problem, when I click on a button to buy Medicine, the Money value change to -750 and not for example 2000-750= 1250
Here is the script:
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if plr.Settings.Money.Value >= 750 then
game.ReplicatedStorage.BuyMoneyValue:FireServer()
end
end)
You’re indexing a nil value, so I guess that ‘Medicine’ or something doesn’t exist in the directory you’re indexing. Also I suggest checking if player has enough money on the server, not in the local script becuase this is not safe.
Seems to work fine except for the money going from 750 to -750 (might be my fault trying to recreate the script in studio)
Assuming this might be one of the issues:
game.ReplicatedStorage.BuyMoneyValue:FireServer()
Try doing this instead: game.ReplicatedStorage.BuyMoneyValue:FireServer(plr)
EDIT: Nevermind, didn’t notice you changed the script.
Did I solve your problem? Now please give us the complete code because the one you provided does not contain the part where money is being subtracted from the players money count.
It’s happening because you have to check if player has enough money on the server, not in the local script, because of the connection latency you will have problems like that.