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

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

Asked by 5 years 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. DeceptiveCaster 3761 — 5y
0
thx. i really need to start tinkering with the events you can do with the Players object in studio. User#28017 0 — 5y
0
the script does print out the velocity after increasing it. it was increased, but my player isnt launched. what does this mean? User#28017 0 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years 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. User#28017 0 — 5y
0
Could you show me your current script? EternalScythe 222 — 5y
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 User#28017 0 — 5y
0
I saw the problem, I edited my before answer, Use it and tell me if it works. Hope I helped, again. EternalScythe 222 — 5y
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? User#28017 0 — 5y
0
There, edited, No problem. EternalScythe 222 — 5y
Ad

Answer this question