So my script makes it so that the player looks right when player's mouse enters a gui. the only problem is, I set it so that the function only works when a value is true. It still functions. Here is the script!:
if script.Heli6Ready.Value == true then player.PlayerGui.Ermg.Left.MouseEnter:connect(function() if script.LookingLeft.Value == false then script.LookingLeft.Value = true camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(181), 0) wait(0.01) camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(182), 0) wait(0.01) camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(183), 0) end end) script.Heli6Ready.Value = false script.Heli4Ready.Value = true end
Your condition on line 01 affects the statement:
player.PlayerGui.Ermg.Left.MouseEnter:connect( somefunvalue )
Notice that this is the connection, and not actually the event firing. This only happens once.
It is the execution of somefunvalue
which happens repeatedly, and which needs to check:
player.PlayerGui.Ermg.Left.MouseEnter:connect(function() if script.Heli6Ready.Value == true then if script.LookingLeft.Value == false then script.LookingLeft.Value = true camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(181), 0) wait(0.01) camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(182), 0) wait(0.01) camera.CameraSubject = target camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(0, math.rad(183), 0) end end end)
I cannot guess from what you have provided where these two lines belong:
script.Heli6Ready.Value = false script.Heli4Ready.Value = true
Style suggestion:
You don't need to check if a value is == true
.
if script.Heli6Ready.Value then
Is shorter and usually clearer.
Similarly, instead of using == false
, use
if not script.LookingLeft.Value then