Velocity not working

I made a script that if you touch a part, it sends you up in sky with velocity, but this only works when the part is not anchored. But in my case i want it anchored.

1 Like

that is because anchored parts stay in place and cant have well, gravity.

No i mean its a script like where you touch a part and if you touch the part, it sends a PLAYER in the sky with velocity. But it only works with velocity.

1 Like

It’d be cool to see the script.

Well. I dont know how to. So yeah still waiting for someone.

You copy paste it and then you click that icon and paste ur text
image

Copy and paste what and btw here is my script :

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		hit.Parent.HumanoidRootPart.Velocity = Vector3.new(0, 100, 0)
	
	end
end)

so this is just in an anchored part?

Oh you meant see my script. I didnt knew that i thought u meant the script at the end.

Yeah it is. And if i touch the part it sends me up 0.00000001 studs or something.

how high do you want it though?

100 studs as it says it in the script.

i actually dont know why this occurs. pretty weird considering it works when its unanchored

I dont know too… So yeah im stuck with this now.

This code should work with an anchored part

local debris = game:GetService("Debris")

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent
	
	local humanoid = char:FindFirstChild("Humanoid")
	if humanoid then
		local rootPart = humanoid.RootPart
		if rootPart and rootPart.Velocity.Y < 200 then
			local bv = Instance.new("BodyVelocity")
			bv.MaxForce = Vector3.new(0, 10e6, 0)
			bv.Velocity = Vector3.new(0, 100, 0)
			bv.Parent = rootPart
			debris:AddItem(bv, 1)
		end
	end
end)
1 Like

that was what i was trying to do but you beat me to it haha kudos

The velocity of HumanoidRootPart cannot be changed by the server because Network Ownership belongs to the player.

Thanks bro it works. Saved me alot of time!

oh i didnt knew that but wait it works when it is unanchored so why?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.