Job Script not working [help]

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)

Remove that and try again.

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.

1 Like

i tried and it got stuck in the same place

Yeah, that’s the point. Set if the CashierSlots is only to 0.

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)
1 Like

This is checking if the CashierSlots’ value is 0 or more than 0. Try changing the operator to this: <=


And maybe try switching these around?

aint no way all i messed up was ‘>’ this worked thanks

2 Likes

So basically what I said in my post?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.