Hi, I’m attempting to make a script that gradually makes the player fly up, so that its smooth, but I’m not quite sure how to do that. Could anyone help me out? This is my code so far. It works, but I want the player to be able to go down, but I’m not sure how to disconnect the .Stepped.
local remote = script.Parent
remote.OnServerEvent:Connect(function(player)
local char = player.Character
local velocity = char.LinearVelocity
local moved = 0
local step = game:GetService("RunService").Stepped:Connect(function(t, dt)
if moved <= 200 then
moved += 1
velocity.LineVelocity += 0.5
print(velocity.LineVelocity)
end
end)
end)
local remote = script.Parent
remote.OnServerEvent:Connect(function(player)
local char = player.Character
local velocity = char.LinearVelocity
local moved = 0
local stepConnection = nil
stepConnection = game:GetService("RunService").Stepped:Connect(function(t, dt)
if moved <= 200 then
moved += 1
velocity.LineVelocity += 0.5
print(velocity.LineVelocity)
else
stepConnection:Disconnect()
stepConnection = nil
end
end)
end)