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

How do I make the force apply to the front of the player?

Asked by 3 years ago
Edited 3 years ago

Hi I'm trying to make a throwing system but I do not know how to make the force apply to the front of the player, can you guys help me?

    local force = 0
local Break = false
local maxForce = 60

mouse.KeyDown:connect(function(code)
    if code == "q" then
        while wait(.1) do
            force = force + 1

            if Break == true then
                break
            end

            if force > maxForce then
                break
            end
        end
    end
end)

mouse.KeyUp:connect(function(CODE)
    if CODE == "q" then
        Break = true
        for _, v in pairs(inventory:GetDescendants()) do
            if v:FindFirstChild("selected") then
                for _, x in pairs(v:GetChildren()) do
                    if x:IsA("UnionOperation") or x:IsA("Part") or x:IsA("MeshPart") then
                        x.Parent = workspace
                        x.Anchored = false
                        x.Velocity = Vector3.new(0, 0, force) -- Here is the problem
                        x.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
                        force = 0
                        Break = false
                        v.Parent = inventory.avaibleSlots
                        v.Image = "no" -- If you see this and get confused I understand I made the image id to "no" so that there isnt gonna be an image
                    else
                        force = 0
                        Break = false
                    end
                end
            end
        end
    end
end)

Answer this question