Categories > Coding > Lua >

Why is my Lua script not working, Making a tween service for roblox to bypass teleport

New Reply

Posts: 4

Threads: 2

Joined: Jul, 2025

Reputation: 0

Posted

local ts = game:GetService("TweenService")

local teleport = ts:Create(game.Players.LocalPlayer.Character.HumanoidRootPart, TweenInfo.new(3000), {CFrame = CFrame.new(-291.390808, 18.2636929, 1597.67761, 0.467862487, -8.63611689e-08, 0.883801281, 7.26185547e-08, 1, 5.9273134e-08, -0.883801281, 3.64486965e-08, 0.467862487)})
teleport:Play()
  • 0

  • Comment

Posts: 7

Threads: 0

Joined: Jun, 2023

Reputation: 0

Replied

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

 

player.CharacterAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")


local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Linear)


local goal = {
    CFrame = CFrame.new(
        -291.390808, 18.2636929, 1597.67761,
         0.467862487, -8.63611689e-08, 0.883801281,
         7.26185547e-08, 1, 5.9273134e-08,
        -0.883801281, 3.64486965e-08, 0.467862487
    )
}

local teleportTween = TweenService:Create(hrp, tweenInfo, goal)
teleportTween:Play()

Comments

zlpvh 0 Reputation

Commented

is there any way to make it stop lagging, Im firing server to spawn a car, and it flys to the location i want but it keeps lagging back, if this is too much hassle how would i make it easier by connecting a rope to a cargo ship in jailbreak, how would i connect the rope, there is a ropeconstraint and and weld and RopePull im trying to connect the ropepull to the cargo box and make it auto rob

  • 0

  • 0

  • Comment

Added

-- Combined client & server setup
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
 
-- Create RemoteEvent if missing
local remoteName = "SpawnCarEvent"
local event = ReplicatedStorage:FindFirstChild(remoteName)
if not event then
event = Instance.new("RemoteEvent")
event.Name = remoteName
event.Parent = ReplicatedStorage
end
 
-- =======================
-- SERVER-SIDE CODE BELOW
-- =======================
if RunService:IsServer() then
local carTemplate = workspace:WaitForChild("CarModel")
local heli = workspace:WaitForChild("Helicopter")
local crate = workspace:WaitForChild("CargoCrate")
 
local function moveCar()
local car = carTemplate:Clone()
car.Parent = workspace
car:SetPrimaryPartCFrame(CFrame.new(0, 10, 0)) -- spawn position
 
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Linear)
local goal = {CFrame = CFrame.new(-100, 10, 100)}
local tween = TweenService:Create(car.PrimaryPart, tweenInfo, goal)
tween:Play()
end
 
local function attachRope()
local heliAttachment = heli:FindFirstChild("RopeAttach", true)
local crateAttachment = crate:FindFirstChild("CrateAttach", true)
 
if not (heliAttachment and crateAttachment) then
warn("Missing Attachments!")
return
end
 
local rope = Instance.new("RopeConstraint")
rope.Attachment0 = heliAttachment
rope.Attachment1 = crateAttachment
rope.Length = (heliAttachment.WorldPosition - crateAttachment.WorldPosition).Magnitude
rope.Visible = true
rope.Parent = heli
 
local weld = Instance.new("WeldConstraint")
weld.Part0 = heliAttachment.Parent
weld.Part1 = crateAttachment.Parent
weld.Parent = crate
 
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
local goal = {CFrame = heli.PrimaryPart.CFrame * CFrame.new(0, 100, 0)}
local tween = TweenService:Create(heli.PrimaryPart, tweenInfo, goal)
tween:Play()
 
tween.Completed:Connect(function()
weld:Destroy()
rope:Destroy()
end)
end
 
event.OnServerEvent:Connect(function(player)
moveCar()
task.wait(2)
attachRope()
end)
end
 
-- =======================
-- CLIENT-SIDE CODE BELOW
-- =======================
if RunService:IsClient() then
task.wait(1) -- give server time to initialize
event:FireServer()
end
 
 
or
 

-- === SETTINGS ===
local helicopter = workspace:FindFirstChild("Helicopter") -- replace with actual name
local crate = workspace:FindFirstChild("CargoCrate") -- replace with actual name

-- === VALIDATION ===
if not helicopter or not crate then
    warn("Helicopter or CargoCrate not found.")
    return
end

local heliPart = helicopter:FindFirstChildWhichIsA("BasePart")
local cratePart = crate:FindFirstChildWhichIsA("BasePart")
if not heliPart or not cratePart then
    warn("Missing parts for rope.")
    return
end

-- === CREATE ATTACHMENTS ===
local heliAttach = Instance.new("Attachment", heliPart)
heliAttach.Name = "HeliAttachment"

local crateAttach = Instance.new("Attachment", cratePart)
crateAttach.Name = "CrateAttachment"

-- === CREATE ROPE ===
local rope = Instance.new("RopeConstraint")
rope.Attachment0 = heliAttach
rope.Attachment1 = crateAttach
rope.Length = (heliAttach.WorldPosition - crateAttach.WorldPosition).Magnitude
rope.Visible = true
rope.Restitution = 0.1
rope.WinchEnabled = true
rope.WinchSpeed = 10
rope.Parent = heliPart

-- === OPTIONAL: WELD CRATE TO HELI ===
local weld = Instance.new("WeldConstraint")
weld.Part0 = cratePart
weld.Part1 = heliPart
weld.Parent = cratePart

-- === OPTIONAL: LIFT HELI WITH CFrame (may lag if physics owned by server) ===
task.spawn(function()
    local height = 50
    local steps = 50
    for i = 1, steps do
        heliPart.CFrame = heliPart.CFrame + Vector3.new(0, height / steps, 0)
        task.wait(0.05)
    end
end)

 

  • 0

  • Comment

Login to unlock the reply editor

Add your reply

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )