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

Velocity of part not changing?

How the script is supposed to work: When the player presses q a part is spawned outside of their Torso/rootpart. Basically I want the parts velocity to change so it can fly upwards then downwards. The part only flys downwards and I dont know why

local fireball = game.ServerStorage:WaitForChild("Fireball")

game.ReplicatedStorage.Fireball.OnServerEvent:Connect(function(player,cframe)
    local character = player.Character
    local newFireball = fireball:Clone()
    newFireball.CFrame = character.HumanoidRootPart.CFrame

    local jump = Instance.new("BodyVelocity")
    jump.Velocity = Vector3.new(0,20,0)
    wait(2)
    jump.Velocity = Vector3.new(0,-999,0)

    jump.Parent = newFireball

    newFireball.Parent = workspace

    local touchconn

    touchconn = newFireball.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            if hit.Parent.Name ~= player.Name then
                hit.Parent.Humanoid:TakeDamage(0.7)
                wait(0.6)
                if touchconn ~= nil then touchconn:Disconnect() end
                newFireball:Destroy()
            end
        end
    end)
    wait(15)
    if touchconn ~= nil then touchconn:Disconnect() end
    newFireball:Destroy()
end)

1 answer

✓ Accepted answer

think about it. you made the part, set the velocity, waited two seconds, set the velocity again, and then parented it :)

the bodyvelocity doesn’t just act as soon as you parent it. those changes and waits you made have already occurred before you set it.

parent the fireball and bodymover first, then change the velocity.

1 comment

0

thanks!

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