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

How to fix a teleport touchpad if a player is seated in a car?

Asked by
hokyboy 270 Moderation Voter
4 years ago

So i was making a game like camping but i run across a error i tried to make a part that would teleport u but because youre seated it wont teleport you i tried to kill the player before the teleportation but that wont work can anyonehelp me?

-- teleport script

function onTouched(hit)
   local player = game.Players:GetPlayerFromCharacter(hit.Parent)
   if player then
       game:GetService("TeleportService"):Teleport(866960826,player)
  end
end


script.Parent.Touched:connect(onTouched)

-- car script

Car = script.Parent

while true do
 wait(5) 
 for i = 1,100 do
  Car:TranslateBy(Vector3.new(0,0,-1)) 
  wait()

 end
 for i = 1,100 do
  Car:TranslateBy(Vector3.new(0,0,1))
  wait()
 end
end

2 answers

Log in to vote
2
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

Copypasta from my previous post

-- Regular Script inside of the seat

players = game:GetService("Players")
seat = script.Parent
active = false
plr = nil

seat.ChildAdded:Connect(function(child) -- event for the seat
    if not active then -- ensuring this check is false if they are standing
        if child.Name == "SeatWeld" then -- finding the weld
            active = true
            plr = players:GetPlayerFromCharacter(child.Part1.Parent)
            if plr ~= nil then -- ensuring its a player
                plr.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
                wait(4.8)
                game:GetService("TeleportService"):Teleport(866960826, plr)
            end
        end
    end
end)

seat.ChildRemoved:Connect(function(child)
    if child.Name == "SeatWeld" then
        if active == true then
            active = false
            wait()
            -- stop your result
        end
    end
end)

Here's to force the player to jump before teleporting

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        player.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        game:GetService("TeleportService"):Teleport(866960826, player)
    end
end


script.Parent.Touched:Connect(onTouched)
0
Added the teleportation script 0_2k 496 — 4y
0
It does not work can u show me if i add you to team creates? hokyboy 270 — 4y
0
Add me on discord: - ??Speedy ??-#2605 0_2k 496 — 4y
0
Give me your discord actually 0_2k 496 — 4y
View all comments (4 more)
0
?i?sc?o??d#7068 hokyboy 270 — 4y
0
b r u hh hokyboy 270 — 4y
0
https://pastebin.com/jL6c7vVn i made a pasteabin with my name hokyboy 270 — 4y
0
Jesus christ, you made it so nobody can add you.. Add me https://pastebin.com/zXGMbEEX 0_2k 496 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

See this for info

0
the teleporter works if youre not in the car but not if u are idk why could u explain that to me hokyboy 270 — 4y
0
:( sorry User#29913 36 — 4y

Answer this question