i was making a teleporter to another level and i got this message :
16:29:17.734 - Position is not a valid member of Model 16:29:17.734 - Stack Begin 16:29:17.735 - Script 'Workspace.Level1.TeleportStick.Part.TeleportScript', Line 3 - function teleportOnTouch 16:29:17.735 - Stack End
i was confused and until now, i still dont know the answer
the code :
1 | function teleportOnTouch(partTouching) |
2 | if partTouching.Parent:FindFirstChild( "Humanoid" ) then |
3 | partTouching.Parent.HumanoidRootPart.Position = workspace.Level 2. TeleportStick.Position + Vector 3. new( 0 , 5 , 0 ) |
4 | end |
5 | end |
6 |
7 | script.Parent.Touched:Connect(teleportOnTouch) |
1 | partTouching.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace.Level 2. TeleportStick.Position + Vector 3. new( 0 , 5 , 0 )) |
Try using CFrames
Change your code to this:
1 | function teleportOnTouch(partTouching) |
2 | if partTouching.Parent:FindFirstChild( "Humanoid" ) then |
3 | partTouching.Parent.HumanoidRootPart.CFrame = CFrame.new(workspace.Level 2. TeleportStick.Position + Vector 3. new( 0 , 5 , 0 )) |
4 | end |
5 | end |
6 |
7 | script.Parent.Touched:Connect(teleportOnTouch) |
This basically changes where the player's humanoidrootpart is and "teleports" the humanoidrootpart which basically takes the whole player where the humanoidrootpart is