I've came across this problem as well. However, there are some minor things you would need to fix first.
First, you would have to wait for the character to load in because when the player joins, the character is most likely not loaded. To fix this, just simply add player.CharacterAdded:Wait() between lines 1 and 2.
Secondly, the character's HumanoidRootPart may not be loaded in when the character loads in. To fix this, simply wait for the HRP by using :WaitForChild().
I think those are the two main things you would need to fix first before attempting to change the velocity of the HRP.
However, when you do change the velocity of the HRP, it does not seem to change. I found a method that allows the change to happen, however I am not sure why it works. But basically, we change the velocity of the HRP twice with a small wait before each change.
local RunService = game:GetService("RunService")
for i = 1,2 do
RunService.Heartbeat:Wait()
end
2 comments
you can use "char = player.Character or player.CharacterAdded:Wait()" to save a line
I know, but I preffer using this way, it makes more sense on my head