Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

3 comments

1

You can instead do "game.Players:GetPlayerFromCharacter(parent)" for line 4. It's quite literally the same thing, only simpler.

0

thx. i really need to start tinkering with the events you can do with the Players object in studio.

0

the script does print out the velocity after increasing it. it was increased, but my player isnt launched. what does this mean?

1 answer

✓ Accepted answer

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.

6 comments

0

didnt work.

0

Could you show me your current script?

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

0

I saw the problem, I edited my before answer, Use it and tell me if it works. Hope I helped, again.

0

It worked. Could you edit your answer to where you have comments in your script that explain what the script does?

0

There, edited, No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.