Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I stop my character facing my mouse?

I have this script, which you obviously know from the title, makes your character face your mouse. It works amazing, but I don't know how to stop it when I want it to. I tried disconnecting it since it's in a bindable event, and I tried disabling the script as well, but that doesn't work as well. I think you need to change the cframe back to normal, in order to make it stop. But how do I do that? Someone please help!!

Script that does the thing

local conn
conn = game.ReplicatedStorage.MouseFacing.Event:Connect(function(run)
	local player = game.Players.LocalPlayer
	local character = player.Character
	if not character or not character.Parent then
    	character = player.CharacterAdded:wait()
		local tor = character:WaitForChild("HumanoidRootPart")
		local 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
	if not run then
		hum.AutoRotate = false
		tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,tor.Position.y,Mouse.Hit.p.z))
	end
	if run then	
		game:GetService("RunService").RenderStepped:Connect(function()
			if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
				hum.AutoRotate = false
				if Mouse.Hit.p ~= prev_mousehit then
					
					prev_mousehit = Mouse.Hit.p	tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
				end
			else
				hum.AutoRotate = true
			end	
		end)
	end
end)

1 answer

local connection = RBXScriptSignal:Connect(function()

end)
wait(5)
connection:Disconnect()

1 comment

0

I already tried disconnecting, both the remote event and renderstepped. It didnt work.

This discussion is preserved as it was. New answers, comments, and votes are closed.