Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(Still not working?) Need help!

Asked by
Hero_ic 502 Moderation Voter
9 years ago

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?

0
player.Character.Humanoid.WalkToPoint = mouse.Hit.p XToonLinkX123 580 — 9y
0
Did not work :/ where do i place that code? Hero_ic 502 — 9y

Answer this question