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

How do i change the velocity?

when i press p it wont change the velocity, why?

local script:

local mouse = game.Players.LocalPlayer:GetMouse()

local plr = game.Players.LocalPlayer

local body = Instance.new("BodyVelocity")

body.Parent = game.Workspace

mouse.KeyDown:connect(function(key)

if key == tostring("p") then

wait(0.2)

local strength = body.Velocity

body.Parent = plr.Character.HumanoidRootPart

strength = Vector3.new(0, 0, 500)

game.Workspace.Gravity = 0

end

end)

3 comments

0

i am not very good keybind functions but is that how you do it?

0

yes

0

i just dont understand why the velocity wont change

1 answer

Directly change the velocity instead of using a variable.

local x = workspace.Part;
local Pos = x.Position.Y; --let's say its 35

Pos = Pos-5;

print(x.Position.Y, Pos) -->> 35 30

Getting a value from a property and assigning the value to the property then doing something to the variable won't do anything to a property. The variable just holds the number of the property. It doesn't point to anything else.

Just do body.Velocity = Vector3.new(0,0,500).

Also, use UserInputService---GetMouse works fine, but use UIP before sjr04alt bans you for bad code

cough xd

4 comments

0

um what? body doesnt have a position since its not a part so wth is this?

0

this code that u provided is not fit for my code

0

are you stoned

0

Position and Velocity are both vector3's, i assume you're trying to just swipe code and b done with it. if you had an iota of the sense that is called "common" then you could change Position to Velocity but it's okay. i edited the post for you smh

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