Hello, I am trying to make a part move up and down. The part does not depend on the client’s fps so it always has the same speed. The problem only occurs on mobile, when the part goes up, the player goes through the part and falls down, I think the problem is that the fps is changing very fast, and so there might be a hop.
This is a localscript in the starterPlayerScripts.
local RunService = game:GetService("RunService")
-- 1 / 60 is the time between frames if the frame rate is 60 fps.
local MOVE_30_STUDS_TIME = 7 -- change to what you want
local ANGULAR_VELOCITY = 0.0167 / (1 / 60)
local part = workspace:WaitForChild("LollipopUnion22")
local originalCF = part.CFrame
local startTime = os.clock()
RunService.RenderStepped:Connect(function()
local timeSpent = os.clock() - startTime
local ful30StudsMoved = timeSpent / MOVE_30_STUDS_TIME
local modulo2 = ful30StudsMoved % 2
local moveMul = modulo2 <= 1 and modulo2 or (2 - modulo2)
part.CFrame = originalCF * CFrame.Angles(ANGULAR_VELOCITY * timeSpent, 0, 0) + originalCF.RightVector * (moveMul * 50)
end)
Thanks 