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

How can I send these characters in the direction that the players torso is facing?[Solved]

Asked by 6 years ago
Edited 6 years ago

In a game that I am making, I wanted the players to be able to throw other characters in the direction that the player is facing using a tool. I got the tool to send the characters upwards but I don't know how to get them to go forwards. I tried using the mouse's location and multiplying that by the amount of force that I had wanted, but it sent them all over the place, instead of where I had wanted them to go. I tried using cframe and multiplying the force with different values of different objects.I'm just stumped on how to get this to work. Help would be greatly appreciated, thank you in advance, here is the script:

repeat wait() until game.Players.LocalPlayer.Character


local plr = game.Players.LocalPlayer
local MyBody = plr.Character
local mouse = plr:GetMouse()
local dist = 17

mouse.Button1Down:connect(function()
    local pos = script.Parent.Parent:findFirstChild("Torso")
    local Debounce = false
    local b = script.Parent.Parent:GetChildren()
    local dir = mouse.Hit.p
            for index, item in pairs(b) do
            if Debounce == false then   
            if item.Name == "Pikmin" and item.Available.Value == true and (pos.Position - item.Leaf.Position).magnitude < dist then 
            Debounce = true
            item.Available.Value = false
            item:MoveTo(script.Parent.Parent.Head.Position)


            local launch = Instance.new("BodyForce")
            item.Available.Charge.Disabled = false
            launch.Parent = item.Leaf
            launch.Force = script.Parent.Force.Value
            wait(.5)
            launch:remove()
            end

                else
                    return
        end
    end
end)

Answer this question