If statement not doing what it's intended

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! :smiley:

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.

local player = game.Players.LocalPlayer
local PointsNeeded = script.Parent.PointsNeeded
local PlayerPoints =  player.PlayerStats.UpgradePoints

script.Parent.MouseButton1Click:Connect(function()
	if PlayerPoints.Value >= PointsNeeded.Value then
		game.ReplicatedStorage.UpgradePointsAGTChanged:FireServer()
		task.wait(.2)
		script.Parent.Parent.PlayerStats.PlayerAGTNumber.Text = player.PlayerStats.Agility.Value
	else
		print ("Failed, not enough points")
	end
end)

client side should be fixed

but you did not defined the task so it won’t work

no that is a built in library
wait() is deprecated

1 Like