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

Why is bodygyro CFrame arent accurate??

Asked by 3 years ago

So I was creating magic where I used Bodygyro to Aim. In the script, I make that bodygyro cframe always follow the user mouse but somehow it isn't accurate like this.

Aiming script (local script)

mouse.KeyDown:Connect(function(key)
    if key == "q" and isKeyHeld == false then
        if debounce == false and char:FindFirstChild("Fire") then
            if player.Character.Charge.CurrentME.Value > 1100 then
                if script.Parent.Values.QMove.Value == false then
                    debounce = true
                    isKeyHeld = true

                                        local char = player.Character
                                        local root = char:WaitForChild("HumanoidRootPart")

                    local bp = Instance.new("BodyPosition")
                    bp.Name = "Firebp"
                    bp.Parent = root
                    bp.P = bp.P * 4
                    bp.D = 200
                    bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
                    bp.Position = root.Position
                    local bg = Instance.new("BodyGyro")
                    bg.Name = "Firebg"
                    bg.Parent = root
                    bg.P = bg.P * 4
                    bg.D = 200
                    bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
                    while isKeyHeld == true do
                        bg.CFrame = CFrame.new(root.Position,mouse.Hit.p)
                        wait()
                    end
                end 
            end
        end
    end
end)

Fireball cloning script

remotes.FireRemote.OnServerEvent:Connect(function(plr, skill,mouse)
    if skill == "Fireball" then
        repeat wait() until keyholded == false
        local char = plr.Character
        local newblast = assets.QMove.FireQ:Clone()
        newblast.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0,0,-4)

        local bv = Instance.new("BodyVelocity", newblast)
        bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        bv.Velocity = (char.HumanoidRootPart.CFrame.lookVector * 100)

        newblast.Parent = plr.Character.HumanoidRootPart

        local name = Instance.new("StringValue",newblast)
        name.Name = "Owner"
        name.Value = plr.Name

        local shootsound = script.Parent.Sounds.shoot:Clone()
        shootsound.Parent = plr.Character.HumanoidRootPart
        shootsound:Play()
        shootsound:Destroy()

        newblast.damagebonus.Value = damagebonus

        while wait() do
            if (newblast.Position - char.HumanoidRootPart.Position).magnitude > 800 then
                newblast:Destroy()
            end
        end
    end
end)

Answer this question