Hi,
I want to make a script that creates a new part which is a sphere and also add velocity to it so that it goes into the direction the player is facing for like 2-3s before completely stopping. I never worked with this kind of stuff, I tried something but it doesn’t seem to work really.
It’s just a simple test:
local part = script.Parent
part.Velocity = part.CFrame.lookVector * 20
repeat
part.Velocity += Vector3.new(0, 0, .25)
print(part.Velocity)
wait(0.01)
until part.Velocity >= Vector3.new(0, 0, 0)
It worked before but then changed directions and now it shows me an error that I am trying to compare Vector 3 to Vector 3
local part = script.Parent
local Db = true
part.Touched:Connect( function()
if Db == true then
Db = false
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = part
BodyVelocity.Velocity = Vector3.new(0, 50, 0)
wait(2)
Db = true
wait(1)
BodyVelocity.Parent = nil
end
end)
I think yes, (don’t tested it) but if when character is added you create a little block in front of it and weld to the humanoid root part you can make:
then the velocity will be pointing to the little block, so if the block is in front of the player the velocity will be to the direction the player is facing