I have this local script that is connected a bindable event. It works when a parameter from the bindable event is true, otherwise it wouldn't work. However, when I set it to false, it only changes the value once and then goes back to being true even though I never did change the parameter. I have it printed to true if its running, so every time I move my mouse, it would print like 100x trues. When I set it to false, it only prints false once and then goes back to printing tons of trues, which seems really weird. Anyways, please help!
Simplified version of what this script looks like
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Z then
game.ReplicatedStorage.MouseFacing:Fire(true)
end
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Z then
game.ReplicatedStorage.MouseFacing:Fire(false)
end
end)
end)
Fired Local Script
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
tor = character:WaitForChild("HumanoidRootPart")
hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local tor = character.HumanoidRootPart
local hum = character.Humanoid
player.CharacterAdded:Connect(function()
character = player.Character
tor = character:WaitForChild("HumanoidRootPart")
hum = character:WaitForChild("Humanoid")
end)
local Mouse = player:GetMouse()
local prev_mousehit
local move
local conn
conn = game.ReplicatedStorage.MouseFacing.Event:Connect(function(run)
move = Mouse.Move:Connect(function()
print(run)
if not run then
hum.AutoRotate = true
move:Disconnect()
return move:Disconnect()
end
if (cam.Focus.Position-cam.CoordinateFrame.Position).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.Position ~= prev_mousehit then
prev_mousehit = Mouse.Hit.Position
tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.Position.x,Mouse.Hit.Position.y,Mouse.Hit.Position.z))
end
end
if not run then
hum.AutoRotate = true
move:Disconnect()
return move:Disconnect()
end
end)
end)
