Boolean check returns "false info"?

  1. What do you want to achieve?
    I’d like for when my proximity prompt is triggered, it checks if 2 boolean values located in ReplicatedStorage are true and then proceeds with playing an animation.

  2. What is the issue?
    The animation plays despite BOTH bool values being false, basically it does not care if the bools are false or true it just goes around the if-statement

  3. What solutions have you tried so far?
    else statement OUTCOME: it just runs the else statement EVEN when the bool values are BOTH true
    Nested IF-Statement OUTCOME: had the same issue
    __Used WaitForChild when looking up the boolean values

-- THIS CODE IS A SERVER-SIDE SCRIPT INSIDE THE PROXIMITY PROMPT
local prox = script.Parent
local Replic = game:GetService("ReplicatedStorage")


prox.Triggered:Connect(function()
	if Replic:WaitForChild("term1") == true then
		if Replic:WaitForChild("term2") == true then
			local doorHumanoid = game.Workspace:WaitForChild("DOOR").Humanoid
			local anim = Instance.new("Animation")
			anim.AnimationId = "http://www.roblox.com/asset/?id=13971995451"
			anim.Parent = doorHumanoid
			local track = doorHumanoid:LoadAnimation(anim)

			track:Play()
			task.wait(track.Length * 0.99)
			track:AdjustSpeed(0)
		end
		
	else
		print("No blud")
	end
	
end)	

I know for sure that the bools are true because I search them up in the explorer at runtime

Try adding .Value at the end of both WaitForChild()-s. Currently you are trying to compare a returned instance to a boolean value. Example: Replic:WaitForChild(“term1”) == true will compare the child, in this case the boolean value, to the boolean value true. But if you do Replic:WaitForChild(“term1”).Value == true, that will find its value and compare it to the boolean, which should work properly. Hopefully I understood your topic correctly.

EDIT:
The code change should be in just these two lines:

	if Replic:WaitForChild("term1") == true then
		if Replic:WaitForChild("term2") == true then

Change it to:

	if Replic:WaitForChild("term1").Value == true then
		if Replic:WaitForChild("term2").Value == true then
1 Like

Thank you! I’m so used to the JS way of doing it :sob:

1 Like

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