Zipline is very laggy when testing in server

Zipling works perfectly when testing in client but is very choppy on server. My ping is around 100m/s, I want this to be a good experience for everyone.

How can I fix this any ideas?

local pp = Instance.new("ProximityPrompt", script.Parent:WaitForChild("Start"))
pp.ActionText = "Press E to ride"
pp.ObjectText = "Ziplines"

local line = Instance.new("Beam", script.Parent.Start)
line.FaceCamera = true
line.Transparency = NumberSequence.new(0)
line.Width0 = 0.2
line.Width1 = 0.2

-- Set the color of the beam
line.Color = ColorSequence.new(Color3.new(0.333333, 0.333333, 0.333333))  -- Red color

local a0 = Instance.new("Attachment", script.Parent.Start)
local a1 = Instance.new("Attachment", script.Parent.End)

line.Attachment0 = a0
line.Attachment1 = a1

pp.Triggered:Connect(function(plr)
	pp.Enabled = false

	local hrp = plr.Character.HumanoidRootPart

	local ziplineOffset = Vector3.new(0, hrp.Size.Y * 2, 0)

	local distance = (script.Parent.Start.Position - script.Parent.End.Position).Magnitude

	hrp.Anchored = true
	hrp.CFrame = script.Parent.Start.CFrame - ziplineOffset

	wait(0.2)

	for i = 0, distance / 3 do
		game:GetService("RunService").Heartbeat:Wait()
		hrp.CFrame = hrp.CFrame:Lerp(script.Parent.End.CFrame - ziplineOffset, i / distance)
	end

	hrp.Anchored = false
	pp.Enabled = true
end)

i mean, doing the movement part on the server will be laggy thats why what i would do personally would be using remote events! Make the movement part on the client, then on the server you create the beams and thats basically it

2 Likes

if you didn’t understand what i mean just ask and i’ll do a code example

That would be great, this gave me a headache

She’s basically talking about something called remote events. Have you heard of them before? They allow you to send values from the client to the server and vice versa. Allowing you to communicate between the server and the client. So this means that the beams will also be seen on the server and not just on the player’s screen.

1 Like