Hi, I wanted to know if there is a possibility of swimming downwards by pressing a key on the keyboard, not by pointing the player’s head downwards but only by lowering the player, (like subnautica do, to understand).
Thanks
Maybe you can add a BodyVelocity to the character to make it sink down until you release E or Q?
isn’t BodyVelocity
deprecated???
what do you mean? press or hold?
BodyVelocity is deprecated, but it doesnt mean that it doesnt work anymore. Also, I am pretty sure he means hold.
ok, thx
Solution:
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:BindAction("Sink", function()
script.Parent:PivotTo(script.Parent:GetPivot() - (script.Parent:GetPivot() / CFrame.new(99,99,99)))
end, false, Enum.KeyCode.Q)
ContextActionService: Unexpected error while invoking callback: Workspace.descreetOP.Sink:4: attempt to perform arithmetic (div) on CFrame
It’s always better practice to not use deprecated objects for a variety of reasons. As stated on the documentation, the alternative is LinearVelocity.
I have looked up LinearVelocity on the internet, I am confused as to how I can set it on the startercharacter from a script
Perhaps you could use the HumanoidRootPart.Velocity property.
--LocalScript
local player = game.Players.LocalPlayer
local humanoid = player.Character:WaitForChild("Humanoid")
local humanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
-- Set the player's velocity directly
humanoidRootPart.Velocity = Vector3.new(0, -50, 0)
Does anyone know why it gives an error with the division?
Also, is BodyVelocity applied in this script?