I am trying to make a game where you search for codes it is called Code Hunters II and it is opening July 14th, 2017 so time is running out. This is a main thing I need done. I placed the script in the part that I want the people to touch to teleport to and script.Name is the id I used to teleport to the map. Please help me the script is below I do not know the bug. It was working a few weeks ago and then suddenly it no longer worked! I want to make then teleport to another game btw.
local s = game:service("TeleportService") local id = script.Name script.Parent.Touched:Connect(function(onTouched) s:Teleport(id) end)
You forgot an argument. Also you need to get the player.
local s = game:service("TeleportService") local id = script.Name script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")~=nil then s:Teleport(id, game.Players:GetPlayerFromCharacter(hit.Parent)) end end)
I took the player who touched and I added it as a argument to the function
If you're using the Teleport
function of TeleportService from the server, you have to supply the Player argument.
You can retrieve the Player object using GetPlayerFromCharacter
.
local s = game:service("TeleportService") local id = script.Name script.Parent.Touched:Connect(function(hit) local p = game.Players:GetPlayerFromCharacter(hit.Parent) --get player if p then s:Teleport(id,p) end end)