Posts: 11
Threads: 4
Joined: Aug 2011
Reputation:
0
I'm trying to make a player that touches this script's parent teleport to a new world, but all it does for me is teleport the player to a certain position. Here's the script:
enabled = true
function OnCollided(hit)
if hit.Parent.Type == "Character" and enabled then
enabled = false
hit.Parent = game:getWorld("outside").World
hit.Position = Vec2D(77.69,63.88)
hit.Parent:remove()
enabled = true
end
end
link(script.Parent.Collided, OnCollided)
[/lua]
Posts: 1,012
Threads: 94
Joined: May 2011
Reputation:
0
I think this is what you need to do:
[lua]
function goTo(id)
local placeId = id + 0
game:load(placeId)
end
link(game.Players.ChildAdded, function(player)
link(player.Chatted, function(chat)
if string.sub(chat, 1, 5) == "goto/" then
goTo(string.sub(chat, 6))
end end) end)
[/lua]
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
08-11-2011, 12:21 AM
(This post was last modified: 08-11-2011, 12:26 AM by Whyrrak.)
No, that's my game teleport script, not a World teleport script...
Hang on a moment and I'll post a world-changing script.
[lua]
enabled = true
function OnCollided(hit)
if hit.Parent.Type == "Character" and enabled then
enabled = false
hit.Parent = game:getWorld("outside").World
local player = game.Players:getChild(hit.Parent.Name)
player.Parent = game:getWorld("outside").Players
hit.Position = Vec2D(77.69,63.88)
hit.Parent.Health = 0
enabled = true
end
end
link(script.Parent.Collided, OnCollided)
[/lua]
Now, assuming your new world is named "outside", that should work. If it looks like it just changed position, are your two worlds nearly identical? If so, it probably worked -- you just can't distinguish between the new World and the old one.