New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Made a player launcher, doesnt work. Know a fix?

Asked by 3 months ago

I created (supposedly) a player launcher. It doesn't work though. What's the problem?

script.Parent.Touched:Connect(function(part)
    local parent = part.Parent 
    local humanPart = parent:FindFirstChild("HumanoidRootPart") 
    local plr = game.Players:FindFirstChild(parent.Name)
    if humanPart and plr then 
        humanPart.Velocity = Vector3.new(0, 10000, 0)
        print(humanPart.Velocity)
    end
end)

the script's Parent is a part named "launcher" in Workspace.

1
You can instead do "game.Players:GetPlayerFromCharacter(parent)" for line 4. It's quite literally the same thing, only simpler. BashCaster 2370 — 3mo
0
thx. i really need to start tinkering with the events you can do with the Players object in studio. CrazyCreatorMLG 142 — 3mo
0
the script does print out the velocity after increasing it. it was increased, but my player isnt launched. what does this mean? CrazyCreatorMLG 142 — 3mo

1 answer

Log in to vote
2
Answered by 3 months ago
Edited 3 months ago

I don't think you have to change velocity. Instead, use BodyForce:

local alreadyhit = false -- setting a variable that will work as debounce
script.Parent.Touched:Connect(function(part) 
    if alreadyhit == false then -- checking if that variable is false, then
        alreadyhit = true -- making it true, so it doesnt repeats
        local char = part.Parent -- getting char
        local player = game.Players:GetPlayerFromCharacter(char) -- getting player
        if player and char:FindFirstChild("HumanoidRootPart") then -- if player exists then
            local bv = Instance.new("BodyVelocity")
            bv.Parent = char.LowerTorso
            bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            bv.P = 25000
            bv.Velocity = char.HumanoidRootPart.CFrame.upVector * 100
-- this creates a bodyvelocity which maxforce is inf, the "P" is 25000, and that will make the player go up. How? It takes the humanoidrootpart upVector, like the y axis, and it multiplys that value by 100.
            game.Debris:AddItem(bv, 2) -- deletes the body velocity after 2 seconds
            alreadyhit = false -- set the variable to false so it can work again
        end
    end
end)

This will throw the player up. I tell you this because I got problems changing velocity, so I recommend using Body Force. Hope I helped.

0
didnt work. CrazyCreatorMLG 142 — 3mo
0
Could you show me your current script? EternalScythe 217 — 3mo
0
script.Parent.Touched:Connect(function(part) local parent = part.Parent local humanPart = parent:FindFirstChild("HumanoidRootPart") local plr = game.Players:GetPlayerFromCharacter(parent) -- Ok then. if humanPart and plr then local bF = Instance.new("BodyVelocity", humanPart) bF.MaxForce = Vector3.new(0, 100, 0) bF.P = 25000 bF.Velocity = Vector3.new(0, 100, 0) wait(2) bF:Destr CrazyCreatorMLG 142 — 3mo
0
I saw the problem, I edited my before answer, Use it and tell me if it works. Hope I helped, again. EternalScythe 217 — 3mo
View all comments (2 more)
0
It worked. Could you edit your answer to where you have comments in your script that explain what the script does? CrazyCreatorMLG 142 — 3mo
0
There, edited, No problem. EternalScythe 217 — 3mo
Ad

Answer this question