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

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

Asked by 4 years ago
Edited 4 years ago

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)

0
Post the script. JayShepherdMD 147 — 4y
0
No edit your post and put it in a code-block. hitonmymetatables 50 — 4y
0
Alright I posted the script Abhay108 0 — 4y
0
Did you test this in the real game,cuz we cannot teleport in studio. TheRealPotatoChips 793 — 4y
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. Abhay108 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
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. Abhay108 0 — 4y
Ad

Answer this question