Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Velocity isn't moving a ball after a few hits?

Asked by 4 years ago

So currently I am working on a mechanic when a ball will get pushed using the Velocity property of the ball. The problem I am having is after the ball gets pushed around a few times after using the velocity property, the ball seems to not longer travel any further than about half a stud. Although the first few times you hit the ball it travels all the way across the box its in if you use enough power.

I am unsure why after a few hits it stops moving and I am unsure if its a scripting problem or more of a physics problem for studio.

The Code Moving The Ball

local force = 0
local event = game:GetService("ReplicatedStorage").Hit  
local stick= workspace.Stick

event.OnServerEvent:Connect(function(plr,distace,power)
    force = power-distace
    if force> 100 then
        force = 100
    elseif force<0 then
        force = 0
    end
    local stickCframe= stick.CFrame
    local lv = stickCframe.lookVector
    script.Parent.Velocity = lv*force
end)

The following is located in a script parented under the ball.

Additional information:

-The script does run every time the event is called.

-The script calling the event waits until the Balls velocity is 0 in all positions (The ball does actually hit 0 in all positions I made sure to test that)

-All custom physical properties are default

-Anchored is always false

If you have any extra questions and want a quick reply contact me on discord: deth836231#6264

Answer this question