Posts: 444
Threads: 78
Joined: Jul 2011
function changeWorld(p)
game.World = game:getWorld("Level0").World
script.Parent.Parent = p
end
link(script.Parent.MouseDown, changeWorld)
It keeps saying Script:2: World is not a property of Root
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
01-03-2012, 04:35 PM
(This post was last modified: 01-03-2012, 04:35 PM by Whyrrak.)
You don't try to set game.World, at least I don't think so.
You need to switch the objects' parents to the other world.
For example,
[lua]
function changeWorld(p, w)
p.Parent = game:getWorld(w).Players
p.Character.Parent = game:getWorld(w).World
script.Parent.Parent = p
end
link(script.Parent.MouseDown, changeWorld)
[/lua]
Posts: 5,683
Threads: 413
Joined: Aug 2012
Reputation:
0
Fixed code:
[lua]
function changeWorld(p, w)
p.Parent = game:getWorld(w).Players
p.Character.Parent = game:getWorld(w).World
end
link(script.Parent.MouseDown, function()
changeWorld(script.Parent.Parent.Parent.Parent, "level0")
end)
[/lua]
This is for a script inside a text button inside a frame inside the main player UI. To get rid of the button and whatnot, I'll let you code that out how you want.