function touched(par)
if game.Name == "Basic Obby 1" then
wait(1)
print(game.Name)
print("Teleporting")
id = game:GetService("AssetService"):CreatePlaceAsync("Obby", "Place For Player!")
local tele = game:GetService("TeleportService")
tele:Teleport(id, getPlayer(par))
end
end
function getPlayer(Part)
local Humanoid = Part.Parent:FindFirstChild('Humanoid')
if (Humanoid ~= nil) then
local Character = Humanoid.Parent
if (Character ~= nil) then
return game:GetService('Players'):GetPlayerFromCharacter(Character)
end
end
end
script.Parent.Touched:connect(touched)
COMMUNITY QUESTION
Why does this script not work?
1 answer
Why make a getPlayer function when you already have a GetPlayerFromCharacter function?
function touched(par)
local player = game.Players:GetPlayerFromCharacter(par.Parent)
if game.Name == "Basic Obby 1" and player then
wait(1)
print(game.Name)
print("Teleporting")
local id = game:GetService("AssetService"):CreatePlaceAsync("Obby: " .. player.Name, game.PlaceId, " Place For Player!")
local tele = game:GetService("TeleportService")
tele:Teleport(id, player)
end
end
script.Parent.Touched:connect(touched)
This discussion is preserved as it was. New answers, comments, and votes are closed.
