This is in two parts. Local script and normal script. They are connected using a remote event. In general it works. But occasionally it can break, but not commonly. I am asking today to get rid of the bugs entirely! Thanks so much you guys are awesome!
Here is normal script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local TriggerEvent = Instance.new("RemoteEvent", ReplicatedStorage) TriggerEvent.Name = "TeleportEventCyan" local plr = game.Players.LocalPlayer local MyBody = plr.Character local flash = script.Light local sparks = script.Sparkles local function onTriggerFired(player) script.Parent.Activated:connect(function() end) end TriggerEvent.OnServerEvent:Connect(onTriggerFired)
And here is local script (Main one)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local TriggerEvent = ReplicatedStorage:WaitForChild("TeleportEventCyan") local plr = game.Players.LocalPlayer local MyBody = plr.Character local mouse = plr:GetMouse() local human = MyBody:FindFirstChild("Humanoid") local Torso = MyBody:FindFirstChild("Torso") or MyBody:FindFirstChild("UpperTorso") and MyBody:FindFirstChild("LowerTorso") local Torso1 = MyBody:FindFirstChild("Torso") or MyBody:FindFirstChild("UpperTorso") local flash = script.Light local sparks = script.Sparkles script.Parent.Activated:connect(function() script.Use:play() flash:Clone() flash.Parent = Torso1 sparks:Clone() sparks.Parent = Torso1 wait(0.25) Torso1.Sparkles:remove() Torso1.Light:remove() local hit = CFrame.new(Vector3.new(-720.8, 20, 35.2)) MyBody:MoveTo(hit.p) Torso:MoveTo(hit.p) end) TriggerEvent:FireServer() function deleteondeath() TriggerEvent:remove() script.Parent:Destroy() end human.Died:connect(deleteondeath)