If statement not working

Hello there users of devforum. I have this script that’ll detect if the muzzle flash for the gun is enabled and that it will print it. Although so far it doesn’t seem to work. I tryed to look for solutions and more on devforum but none seem to work.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.Character:WaitForChild()
local gun = workspace.TurretSystem
local gunmuzzle = workspace.TurretSystem.Muzzle
local closestdisstance = 20

if gunmuzzle.Enabled == true then
	print("yes")
end	

Ideas?

1 Like

If only runs once.
Your can use a while wait() do or hearbeat, but I think this is the best way for you:

gunmuzzle:GetPropertyChangedSignal("Enabled"):Connect(function()
	if gunmuzzle.Enabled then -- With booleans, it's easier to use if then or if not then
		print("yes")
	end
end)
1 Like