i would like to know how to do it when I touch a part. please and thank you
You can’t just ask for code on DevForum, we can only help you when your code errors, you’re stuck on some part of the code etc.
i just need to know a example of adding a bodyvolcity to humanoidrootpart and how would i tweak the bodyvolcity numbers
You can read the documentation, but here’s how you can make a velocity
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = otherPart
BodyVelocity.Velocity = Vector3.new(500, 0, 0)
It in theory should move a part on the X axis with a Velocity of 500
like
local Player = game.Players.LocalPlayer
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = Player.HumanoidRootPart
BodyVelocity.Velocity = Vector3.new(500, 0, 0)
something like this?
No, you need to define the character as a variable
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:FindFirstChild("HumanoidRootPart")
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HRP
BodyVelocity.Velocity = Vector3.new(500, 0, 0)
so if i wanted to make the player go up when its inside i would do this?
local part = game.workspace.part
Function touched()
local part = game.workspace.part
part.Touched:Connect(Function()
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:FindFirstChild("HumanoidRootPart")
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HRP
BodyVelocity.Velocity = Vector3.new(500, 0, 0)
end)
end
Making the player go up would be in the Y axis. (X,Y,Z)
BodyVelocity.Velocity = Vector3.new(0, 500, 0)
Also let me quickly fix up your code
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:FindFirstChild("HumanoidRootPart")
local part = workspace.part
part.Touched:Connect(function()
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HRP
BodyVelocity.Velocity = Vector3.new(0,500,0)
end)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:FindFirstChild("HumanoidRootPart")
local part = workspace.part
part.Touched:Connect(function()
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HRP
BodyVelocity.Velocity = Vector3.new(0,500,0)
end)
This will create a BodyVelocity everytime you touch the part meaning you will need a debounce.
i don’t see bodyvolcity in the player when playtesting