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

how do i make my projectile launch?

Asked by 1 year ago
Tear = game.ReplicatedStorage.tear
local plr = game.Players.LocalPlayer

UserInput = game:GetService("UserInputService")

UserInput.InputBegan:Connect(function(input , gameProccesedevent)
    if input.KeyCode == Enum.KeyCode.E then
        local tearclone = Tear:Clone()
        tearclone.Parent = game.Workspace
        tearclone.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.Head.CFrame.lookVector * 5
    end

end)

this is the script. now it just spawns balls in front of my head. i also have a head turning script so it spawns where i look. now i need to launch the projectile. i don't want it to fly like an anchored object moving in a straight line. i want it to launch like an unanchored object launched and has gravity. thanks.

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

Use the AssemblyLinearVelocity property.

local Tear = game.ReplicatedStorage:WaitForChild("tear")
local plr = game.Players.LocalPlayer

local UserInputService = game:GetService("UserInputService")

local speed = 5 -- YOU CAN CHANGE THIS

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    if not gameProcessedEvent then -- if player is not typing
        if input.KeyCode == Enum.KeyCode.E then
            local char = plr.Character
    if not char or not char.Parent then -- if player's character hasn't loaded
        char = plr.CharacterAdded:Wait()
    end

            local tearclone = Tear:Clone()
            tearclone.Parent = workspace

            tearclone.CanCollide = true
            tearclone.Anchored = false
            tearclone.CFrame = char.Head.CFrame + char.Head.CFrame.LookVector

            tearclone.AssemblyLinearVelocity = tearclone.CFrame.LookVector * speed
        end
    end
end)
0
the projectile isn't launched, it spawns inside of the player's torso pushing him backwards a little, and the projectile slides across the floor. i don't know how to make it launch pakancina 19 — 1y
0
wdym by "launch"? T3_MasterGamer 2189 — 1y
0
There I edited the script. T3_MasterGamer 2189 — 1y
0
i mean like it was shot out of something. like if you picked up something in your hand and throw it, then it falls down pakancina 19 — 1y
View all comments (2 more)
0
I figured out why it didn't work. I forgot to add "CFrame" between "tearclone" and "LookVector" in line 23. I edited the script and it should work now. T3_MasterGamer 2189 — 1y
0
oh my god Thank you!!!! pakancina 19 — 1y
Ad

Answer this question