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

BodyVelocity's velocity property won't change in-game?

Asked by 8 years ago
Edited 8 years ago

Hi!

Today I was using BodyVelocity to create a jet that a player can use to move in the direction of their mouse before the BodyVelocity being destroyed. However, I've run into an issue with changing the Velocity of the BodyVelocity object to move in the direction of the mouse.

It works like a dream in Studio, but when I try it in game, I get this mess.

Here is the code for the velocity:

for i = 1, 20 do
            BodyVelocity.velocity = (Mouse.Hit.p - Character.Torso.Position).unit *80
            Character.Torso.CFrame = CFrame.new(Character.Torso.Position, Mouse.Hit.p)
            wait(0.1)
end

For some reason, this code works perfectly in Studio, but in game, this code refuses to run, meaning all of the code below it never runs, and I remain moving upwards.

What I want to know is why this happens, and how I can fix it.

Thanks!

0
Is it inside a localscript? Reshiram110 147 — 8y
0
No, it is inside of a normal script. DepressionSensei 315 — 8y
1
It must be a local script. Server has no such thing as mouse, and it shouldn't have. Local scripts are special scripts that run on player's computer. ZarsBranchkin 885 — 8y
0
Fixed it DepressionSensei 315 — 8y

Answer this question