.Changed function not working afterall

Hey everyone! Title says it all. No errors in output…

Both LocalScript and BoolValue are in StarterPlayerScriptts

Info.Running.Changed:Connect(function()
	if Info.Running.Value == true and Info.Running.Enabled.Value == true and Info.Moving.Value == true and Info.Crouching.Value == false then
		
	   print("working?")
		
	elseif Info.Running.Value == false then
		
       print("nope")

	end
end)

EDIT: I guess it is the way that I wrote the conditions maybe…
EDIT²: Yes, I checked all conditions and they all met.

Is Running the BoolValue? If so, you should not use .Value on that data type. .Value is mostly just used in IntValues. You can try this for better clarity;

local function runningChanged()
	
	if Info.Running and Info.Running.Enabled and Info.Moving and not Info.Crouching then
		print("Check1; passed")	
	elseif not Info.Running then
		print("Check2; not passed")
	else
		warn("Check3; conditions are incorrect.")
	end

end

Info.Running.Changed:Connect(runningChanged)

task.wait(3)

Info.Running = not Info.Running
1 Like

When working on LocalScripts it’s always best practice to use :WaitForChild as instances can take time to load.

local Info=script.Parent:WaitForChild("Info") -- Change these paths to match your actual paths
local Running=Info:WaitForChild("Running")
local Enabled=Running:WaitForChild("Enabled")
local Moving=Info:WaitForChild("Moving")
local Crouching=Info:WaitForChild("Crouching")

Running.Changed:Connect(function()
	if Running.Value == true and Enabled.Value == true and Moving.Value == true and Crouching.Value == false then

		print("working?")

	elseif Running.Value == false then

		print("nope")

	end
end)
1 Like

Sorry for wasting your time, but the problem was my failed attempt of waiting the character to load by using:

Player.CharacterAdded:Wait()

It caused the script to wait forever and not make the function… sorry once again, I’m dumb :stuck_out_tongue:

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