Hi, I made an elevator with tween service but it jitters also sometimes elevator doesn’t collide and you can fall down. I searched about 4 hours but I couldn’t find a good solution to my issue. I need help. Thanks…
My code:
local rs = game:GetService("ReplicatedStorage")
local ts = game:GetService('TweenService')
local elevator = script.Parent
local elevatorsModel = elevator.Elevators
local elevatorPart = rs:WaitForChild("ElevatorPart")
local elevatorSpawnPoint = elevator.ElevatorSpawnPoint.Position
local elevatorDestroyPoint = elevator.ElevatorDestroyPoint
local elevatorSpawnInterval = 4
local reachSeconds = 60
local reachPosition = elevatorDestroyPoint.Position
local tweenInfo = TweenInfo.new(
reachSeconds,
Enum.EasingStyle.Linear ,
Enum.EasingDirection.InOut,
0,
false,
0
)
while wait(elevatorSpawnInterval) do
local obj = elevatorPart:Clone()
obj.Position = elevatorSpawnPoint
obj.Parent = elevatorsModel
local tw = ts:Create(obj,tweenInfo,{Position = reachPosition})
tw:Play()
tw.Completed:Connect(function()
obj:Destroy()
end)
end
while wait(elevatorSpawnInterval) do
local obj = elevatorPart:Clone()
obj.Position = elevatorSpawnPoint
obj.Parent = elevatorsModel
local tw = ts:Create(obj,tweenInfo,{Position = reachPosition})
tw:Play()
tw.Completed:Wait()
obj:Destroy()
end
Instead of connecting an event to the Completed Signal that is obtained when the tween is completed, wait for the Tween to finish and then destroy it
I don’t know if this will even do anything, it could be something related to tween itself
https://streamable.com/tx3o7g the elevator jitters.(I uploaded to an external website because devforum doesn’t let me to upload it says an error occurred.)
Maybe try changing the EasingStyle you’re using to see which would help out, perhaps try Enum.EasingStyle.Sine. Again, I’m not sure if it’s due to the part itself jittering or if it’s due to the game having to move the player up after moving the part which makes it look like a jitter
Then I believe it’s due to something out of your control, although it could be that my knowledge is limited and I dont know if there’s a solution to this. But every game I see that has something that elevates suffer this issue
Exactly; I believe the server replication to the client is a bit slow, and so the jittering happens. Perhaps use the server for physics but use the client for visuals? I’d attempt to make it more client-sided than server-sided, so that there’s no replication lag.
If it is a replication problem, then the more players on the server, the more jittery it will get.
Hey everyone, I solved the problem with RayAnimate. The jittering problem %99 solved. Thank you all! Here is the tutorial video: DevForumElevator.mp4 - Google Drive