Below is the code I’m currently using, however, the player is lagging so much and it’s not actually smooth at all. I’ve tried switching from RenderStepped to Heartbeat for physics-related and it didn’t work tho. I’ve also added the frequency to multiply it by the change of time during the Heartbeat. Nothing seems to have worked.
local function startDescend(HRP)
local frequency = 10
local connection
connection = RunService.Heartbeat:Connect(function(dt)
if not UserInputService:IsKeyDown(Enum.KeyCode.Space) or detectGround() then
connection:Disconnect()
return
end
SetPlayerPos:FireServer(HRP.CFrame * CFrame.new(0, -frequency, 0))
-- HRP.CFrame = HRP.CFrame * CFrame.new(0, -frequency * dt, 0)
end)
end
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local isDescending = false
local descendConnection
local function startDescend(HRP)
local frequency = 10
if isDescending then return end
isDescending = true
descendConnection = RunService.Heartbeat:Connect(function(dt)
if not UserInputService:IsKeyDown(Enum.KeyCode.Space) or detectGround() then
descendConnection:Disconnect()
isDescending = false
return
end
HRP.CFrame = HRP.CFrame * CFrame.new(0, -frequency * dt, 0)
end)
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Space then
local HRP = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
if HRP then
startDescend(HRP)
end
end
end)
That’s the same thing as I’m doing just in a different approach. What I’m trying to do is to replicate the movement in both client and server smoothly.
I ended up actually using the rope’s physics by increasing the length to make the player down. I was using a custom CFrame update which was using a lot of resources.