so am making a job system this part of the code is where it checks if there slots open for the player etc
but it keeps printing when even tho there is slots open for the player
i marked it on the script
game:GetService("Players").PlayerAdded:Connect(function(Player)
Cashier_Event.OnServerEvent:Connect(function(Player)
if Player.PlayerData.Job.Value == "Cashier" then
print("Player Already Has A Job")
elseif
game.ReplicatedStorage.JobValues.CashierSlots.Value >= 0 then
print("The Cashier Job Doesnt Need Workers") ----------------------[PRINTS HERE]
return
else
print("Player Has Applied For The FastFood Job")
Player.PlayerData.Job.Value = "Cashier"
game.ReplicatedStorage.JobValues.CashierSlots.Value -= 1
end
game.ReplicatedStorage.JobValues.CashierSlots.Changed:Connect(function()
if game.ReplicatedStorage.JobValues.CashierSlots.Value < 0 then
game.ReplicatedStorage.JobValues.CashierSlots.Value = 0
end
end)
end)
end)
Cashier_Event.OnServerEvent:Connect(function(Player)
if Player.PlayerData.Job.Value == "Cashier" then
print("Player Already Has A Job")
elseif
game.ReplicatedStorage.JobValues.CashierSlots.Value >= 0 then
print("The Cashier Job Doesnt Need Workers") ----------------------[PRINTS HERE]
return
else
print("Player Has Applied For The FastFood Job")
Player.PlayerData.Job.Value = "Cashier"
game.ReplicatedStorage.JobValues.CashierSlots.Value -= 1
end
game.ReplicatedStorage.JobValues.CashierSlots.Changed:Connect(function()
if game.ReplicatedStorage.JobValues.CashierSlots.Value < 0 then
game.ReplicatedStorage.JobValues.CashierSlots.Value = 0
end
end)
end)
Aren’t you checking if the slot has greater than or equal to 0 then print that line?
If the value is 0 then the job doesn’t need workers, but if the value is 1, or 200, then it still prints that it doesn’t need workers.
Also make sure that CashierSlots is an IntValue, so that tiny fractions from calculations don’t affect it.
Maybe PlayerData.Job does not change, add a print in the event function to know what it is.
local CashierSlots = game:GetService("ReplicatedStorage").JobValues.CashierSlots
Cashier_Event.OnServerEvent:Connect(function(Player)
print(Player, Player.PlayerData.Job.Value, CashierSlots.Value)
if Player.PlayerData.Job.Value == "Cashier" then
print("Player Already Has A Job")
elseif CashierSlots.Value >= 0 then
return print("The Cashier Job Doesnt Need Workers") ----------------------[PRINTS HERE]
else
print("Player Has Applied For The FastFood Job")
Player.PlayerData.Job.Value = "Cashier"
CashierSlots.Value -= 1
end
end)
CashierSlots.Changed:Connect(function()
if CashierSlots.Value < 0 then
CashierSlots.Value = 0
end
end)