Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My teleport script isn't detecting the player when it is in a moving car, can I get some help?

Hello, I'm in the process of making a similar game like Camping. I have 1 problem though, my Teleport script isn't detecting the player when he hits the main Teleport brick. The player is in a programmed car that moves forward to the main block. He is also in a Seat unable to move until the player is teleported to the next game. Is one of those the issue of my Teleport script not detecting the Player? IF so, is there a way I could fix this issue?

Here is the script:

local TeleportService = game:GetService("TeleportService")
local gameID = 4459522530


function onTouched(hit)
 local player = game.Players:GetPlayerFromCharacter(hit.Parent)
 if player then
 TeleportService:teleport(gameID, player)
 end
end

script.parent.Touched:Connect(onTouched)

5 comments

0

Post the script.

0

No edit your post and put it in a code-block.

0

Alright I posted the script

0

Did you test this in the real game,cuz we cannot teleport in studio.

0

Yeah I did test it in an actual server, it's more of that the game isn't detecting the player when it's in the car.

1 answer

Try this put a regular script in the part that you are trying to make that teleports you

local TeleportService = game:GetService("TeleportService")
local Place = (Game Id here)

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		TeleportService:Teleport(Place, player)
	end
end)

1 comment

0

Here is the issue, it's not the teleport script, it's more of how the game isn't detecting the player when it's in the car. This script would work if I just walked to the part, but I want the player to teleport when it's in the car.

This discussion is preserved as it was. New answers, comments, and votes are closed.