I’m using tween service to move a player to a part.
This is what I got:
How could I make this smoother?
All the parts’ cancollide are off.
Code:
local tweenService = game:GetService("TweenService")
local zipline = workspace:WaitForChild("Obstacle"):WaitForChild("Zipline")
local partA = zipline:WaitForChild("A")
local partB = zipline:WaitForChild("B")
local function tweenPlayerToPart(player)
local character = player.Character
if not character then return end
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if not humanoidRootPart then return end
local moveTweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
tweenService:Create(humanoidRootPart, moveTweenInfo, {Position = partB.Position}):Play()
moveTween.Completed:Wait()
end
local db = false
local function onTouch(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and db == false then db =true
tweenPlayerToPart(player)
end
end
partA.Touched:Connect(onTouch)
It isn’t smooth because you are tweening it on the server, this is bad and unoptimised because of how much network outcome it sends so just play the tween on the client for smoother and more accurate results
I see you are tweening the player consider using lerping instead on a runservice connection as it is the exact same as tweening but allows for more control over every frame of the lerp and it doesnt overload the server as much
I was not stating they are not faster on the client (it is common knowledge that they are faster on the client), rather that they are not that dramatically less performant on the server.
OP is likely using client tweens. Their main problem is not anchoring the HumanoidRootPart thus the character is being affected by gravity whilst being tweened giving this glitchy effect.