Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleport To A Moving Part?

Asked by 5 years ago
Edited 5 years ago

Hey guys, I'm currently making a game where a teleport moves you to a train (that's moving). I keep getting an error in the output box.

Script -

--By CommanderStitchz594.
--Working Teleport
--Make sure the Part to teleport to is in the same group as this Part.
--Feel FREE to Copy, Abuse and Covet!
local Teleport = "Part2" --Put the name of the Part between the ""s.
function Touch(hit) --Indicates that the Part has been Touched.
    if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
    local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
        hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
script.Parent.Touched:connect(Touch) --Listens out for Touchers.

The Output Box States -

09:27:11.701 - Stack Begin

09:27:11.701 - Script 'Workspace.Part1.Script', Line 7

09:27:11.702 - Stack End

09:27:11.804 - Workspace.Part1.Script:7: attempt to index a nil value

Is there a fix, or is this just impossible for roblox?

Thanks In Advance!

0
Put Part 2 in workspace, then change line 7 to this: if script.Parent.Locked == false and workspace:FindFirstChild(Teleport).Locked == false then BuDeep 214 — 5y
0
Sorry, Name Of What? CommanderStitchz594 2 — 5y
0
name of ur game LUCATIVIOMAD 31 — 5y
0
also caps LUCATIVIOMAD 31 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Put Part 2 in workspace, then change line 7 to this: if script.Parent.Locked == false and workspace:FindFirstChild(Teleport).Locked == false then That's what someone wanted to tell you, and used comments instead.

0
Thanks! I saw you asked a question. What name would you like? CommanderStitchz594 2 — 5y
Ad

Answer this question