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

Why won't this Body Gyro script work?

Asked by 8 years ago

I wanted to make it so when you press 'Shift' it makes your Character face the Position of the Mouse... However, it won't do that and I have no clue as to why it won't work correctly... This script is a LocalScript inside of StarterGui....

ocal player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bg = Instance.new("BodyGyro")
bg.maxTorque = Vector3.new(400000000, 400000000, 400000000)
bg.D = 200
bg.P = 3050
mouse.KeyDown:connect(function(key)
    if string.byte(key) == 48 then
        local torso = player.Character.Torso
        bg.Parent = torso
        debounce = true
    while debounce == true do
        bg.CFrame = CFrame.new(mouse.hit.p)
        print(bg.CFrame)
        wait()
    end
    end
end)
mouse.KeyUp:connect(function()
    debounce = false
    bg:remove()
end)

Thank you for reading the whole question and I hope someone can help me out!

0
Isn't like like shift lock? yoshi8080 445 — 8y
0
well similar yoshi8080 445 — 8y
0
Yeah, I turned my shift lock off to see if it works. KingLoneCat 2642 — 8y
0
Please use UserInputService and test. KeyDown is deprecated and should not be used for future projects. XAXA 1569 — 8y
0
I haven't learned how to use "UserInputService" yet.... Plus what's wrong with KeyDown? KingLoneCat 2642 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Make Sure That The Part That You Use To Move It With BodyGyro Did Not Anchored

Ad

Answer this question