"If" statement doesn't work with checking player GUI status

hello, my fellow amer- I mean devs!

so apparently I was making a script that basically clones Gui frames and puts them inside “PlayerGui”. the way I’ve done this is very simple, I basically made a ProximityPrompt so when it gets triggered, it should take the players action named “hit” and then goes to the “hit” parent and eventually to “PlayerGui” where a GUI clone should be put inside, at first it did work…until I added the “If” statement on the script, I added it so it checks if a value is true or false, which is located inside the “PlayerGui”, I don’t know why it stopped honestly since I’m not that much of a scripter, but I do assume that it has something to do with local scripts or whatever.
please check the code and screenshots, it should explain my gibberish explanation :confused:

script.Parent.Triggered:Connect(function(hit)
	
-------------------------------------------------------------- [ON JOB]	
	
	if hit.PlayerGui.JobGui.JobExam.InJob == true then

		local Frame = script.Parent.InJobFrame:Clone()
		Frame.Parent = hit.PlayerGui.JobGui
		Frame.PupUp:Play()

	end
	
-------------------------------------------------------------- [OFF JOB]	
	
	if hit.PlayerGui.JobGui.JobExam.InJob == false then
		
		if hit.PlayerGui.JobGui.JobExam.JobDone == true then

			hit.PlayerGui.JobGui.JobExam.JobDone = false

			local Frame = script.Parent.C50:Clone()
			Frame.Parent = hit.PlayerGui.JobGui
			Frame.PupUp:Play()
			
		else
			
			local Frame = script.Parent.ProgramJob:Clone()
			Frame.Parent = hit.PlayerGui.JobGui
			Frame.PupUp:Play()
			
		end
		
	end
	
	script.Parent.MaxActivationDistance = 0
	wait(5)
	script.Parent.MaxActivationDistance = 15
end)

image
image

help would be much appreciated :pray:

This is not working due to the fact you’re checking the Object itself instead of it’s value. IntValues, StringValues, and other types of values have a Value property, Which is where the value of the Object is kept at.

You should also take in consideration that if you’re modifying the value on the Client, It won’t work on the Server — As the value will only be available to the Client and won’t be replicated to the Server.

-- For checking the Value
if hit.PlayerGui.JobGui.JobExam.InJob.Value == true then

end

-- For setting the Value
hit.PlayerGui.JobGui.JobExam.InJob.Value = true
3 Likes

I’m an actual moron, I keep doing this same mistake of forgetting to add “.value”, anyways, thx a lot for the help I guess, and yes, I am aware of it taking an effect on the client only.