I got a problem when i'm trying to make a part that when you touch it, it make you teleport to another place, like the egg hunt (2014).
I'm working on a new game, I try to use no free models, please help me to know about this part of the job, please help me to fix it.
function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):TeleportToSpawnByName(141257134, "SpawnLocation", player) end end
Thank you. --TheDarkSpy07--
You did not define when the function 'onTouched' should be called, here is how you can fix it:
function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):TeleportToSpawnByName(141257134, "SpawnLocation", player) end end game.Workspace.Part.Touched:connect(onTouched)--Just added this, it determines when to run your function.
Or just make this all easier and insert the script into the part and do this
script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then game:GetService("TeleportService"):TeleportToSpawnByName(141257134, "SpawnLocation", player) end end)