I'm working on a game where when you go in a certain mode it makes the player follow the mouse but for some reason when i turn it off it still follows the mouse,

"Mode" is a local variable i made for when player switches modes with the shift key.

Mode 0 = Default and Mode 1 = Battle (Yes i'm making a battle game)

mouse.KeyDown:connect(function(key)

if mode == 1 then
	wait(.5)
	if string.byte(key) == 48 then
	mode = 0
	end
end

if mode == 0 then
	if string.byte(key) == 48 then
	mode = 1
	end	
end

-- Follow Mouse
game:GetService("RunService").RenderStepped:connect(function()
if player.Character.Humanoid.Health > 0 and mode == 1 then
		player.Character.Torso.CFrame = CFrame.new(player.Character.Torso.Position, 		   	  Vector3.new(mouse.Hit.p.X, player.Character.Torso.Position.Y, mouse.Hit.p.Z))
else
	player.Character.Torso.CFrame = nil
	end
end)
end)

I've been really confused and i hope one of you can help?

2 comments

0

player.Character.Humanoid.WalkToPoint = mouse.Hit.p

0

Did not work :/ where do i place that code?