If then script not working

For some reason my if then script dosent work it just kills me everytime. Any help?

		if player.PlayerGui.Flashlight.Enabled == true then
				print("on")
				script.Parent.Transparency = 1
				wait(0.5)
				script.Parent.Transparency = 0
				script.Playing.three.Value = true
			else
				print("off")
				workspace:FindFirstChild(player.Name).Humanoid.Health = 0
			end
2 Likes

Are you running this if statement in an event? Can we see the full code?
Because maybe the Flashlight.Enabled never went true

1 Like

It was true I checked but here is the full code,

local day1Wait = 6
game.Players.PlayerAdded:Connect(function(player)
	if game.Workspace.Day.Value == 1 then
		script.Playing.Value = true
	end
	script.Playing.one.Changed:Connect(function(o)
		if script.Playing.one.Value == true then
			script.Playing.one.Value = false
			script.Parent.Position = game.Workspace.Locations.One.Position
			script.Parent.Rotation = game.Workspace.Locations.One.Rotation
			wait(day1Wait)
			script.Playing.two.Value = true
		end
	end)
	script.Playing.two.Changed:Connect(function(t)
		if script.Playing.two.Value == true then
			script.Playing.two.Value = false
			script.Parent.Position = game.Workspace.Locations.Two.Position
			script.Parent.Rotation = game.Workspace.Locations.Two.Rotation
			wait(day1Wait)
			script.Playing.three.Value = true
		end
	end)
	script.Playing.three.Changed:Connect(function(th)
		if script.Playing.three.Value == true then
			script.Playing.three.Value = false
			script.Parent.Position = game.Workspace.Locations.Three.Position
			script.Parent.Rotation = game.Workspace.Locations.Three.Rotation
			wait(day1Wait)
			script.Playing.four.Value = true
		end
	end)
	script.Playing.four.Changed:Connect(function(f)
		if script.Playing.four.Value == true then
			script.Playing.four.Value = false
			script.Parent.Position = game.Workspace.Locations.Four.Position
			script.Parent.Rotation = game.Workspace.Locations.Four.Rotation
			wait(1)
			if player.PlayerGui.Flashlight.Enabled == true then
				print("on")
				script.Parent.Transparency = 1
				wait(0.5)
				script.Parent.Transparency = 0
				script.Playing.three.Value = true
			else
				print("off")
				workspace:FindFirstChild(player.Name).Humanoid.Health = 0
			end
		end
	end)
	if script.Playing.Value == true then
		script.Playing.Value = false
		wait(math.random(22, 30))
		script.Playing.one.Value = true
	end
end)


1 Like

Does the output ever print “on”?

1 Like

No only off jsjjshsbebeh
Hdhdhdhfnhdhdhd

Is this a Server Script or a Local Script? UI property changes are not replicated to the server (if you are using a server script).

1 Like

Try changing the Changed function and making it say GetPropertyChangedSignal(“Value”) and see if that makes a difference.

It detects the value change but not the ui change

1 Like

How does the value change? from the remote event?

no from the script, but thats not the problem only the gui does not connect even if it is enabled

1 Like

What script local script? If so then the server can’t check that the value has changed.

I said GUI not value. and it is a server script edit it kills me every time

2 Likes

Oh that’s because the server can’t access the players GUI.
Oh nvm it can, I was thinking of PlayerScripts

Why? (fdsfdsfsdfdfdsfsdfds) hjjgjhgj

1 Like

Are you sure that the Flashlight’s value changes from a server script. You said that it only prints off

What I’m guessing is that your only changing the value from a local script.

I think it’s because you didn’t change the value in the server script because if you change the value in a local script it only changes for the client not the server

1 Like