Hi! I recently make a new project that basically give player stats and allow them to spend points to upgrade them. However the if statement is not doing what it’s suppose to do. It cannot check whether the PlayerPoints is bigger than the PointsNeeded or the same as PlayerPoints There is no errors in the output. Can anyone point out what the problem is? Thx!
Code to detect if it’s changed and fire remote event (one of the scripts since they are basically the same thing)
local player = game.Players.LocalPlayer
local PointsNeeded = script.Parent.PointsNeeded.Value
local PlayerPoints = player.PlayerStats.UpgradePoints.Value
script.Parent.MouseButton1Click:Connect(function()
if PlayerPoints >= PointsNeeded or PlayerPoints == PointsNeeded then
game.ReplicatedStorage.UpgradePointsAGTChanged:FireServer()
wait(.2)
script.Parent.Parent.PlayerStats.PlayerAGTNumber.Text = player.PlayerStats.Agility.Value
else
print ("Failed, not enough points")
end
end)
Server that recived the code and give changed server-side so it can get saved:
game.ReplicatedStorage.UpgradePointsAGTChanged.OnServerEvent:Connect(function(player)
local PlayerAGT = player.PlayerStats.Agility
local PlayerUpgradePoints = player.PlayerStats.UpgradePoints
local PointsNeeded = player.PlayerGui.PlayerStatsUI.MainFrame.PlayerAGTUpgrade.PointsNeeded.Value
PlayerUpgradePoints.Value = PlayerUpgradePoints.Value - PointsNeeded
PlayerAGT.Value = PlayerAGT.Value + 10
end)
The server side is ok, but not for the client side.