Can someone tell me what is wrong with this script?
#1
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]
Reply
#2
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]
[Image: chaosthegreat.png]
Reply
#3
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.
Reply
#4
(08-11-2011, 12:21 AM)Qwertygiy Wrote: 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.

Okay, here's the working version:
[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)
enabled = true
end
end

link(script.Parent.Collided, OnCollided)
[/lua]

I think you forgot to add a parent Tongue
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)