some scripting stuffs - Printable Version +- 2DWorlds Forums (http://2dworlds.buildism.net/forum) +-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4) +--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13) +--- Thread: some scripting stuffs (/showthread.php?tid=1683) |
some scripting stuffs - -_- - 04-02-2011 [lua]p = Instance.new("Part") -- Create a new brick p.Parent = game.Workspace -- The part (a grey brick, by default) has a parent, the workspace wait(1) p.Parent = nil -- The part now has no parent (and so it disappears from view, but not from memory). wait(1) p.Parent = game.Workspace -- part still exists because it is referenced by the variable 'p' wait(1) p.Parent = nil -- part disappears again (it has no parent) p = nil -- part is no longer referenced by anything, so it gets picked up by the garbagecollector [/lua] LEGIT BRO RE: some scripting stuffs - Paradox - 04-02-2011 I moved this to the correct forum. RE: some scripting stuffs - Jacob__mybb_import1 - 04-02-2011 Wrong game. [lua] p = create("Box") -- Create a new box p.Parent = game.World -- The part (a grey box, by default) has a parent, the world sleep(1) p.Parent = nil -- The part now has no parent (and so it disappears from view, but not from memory). sleep(1) p.Parent = game.World -- part still exists because it is referenced by the variable 'p' sleep(1) p.Parent = nil -- part disappears again (it has no parent) p = nil -- part is no longer referenced by anything, so it gets picked up by the garbagecollector [/lua] RE: some scripting stuffs - Elite - 04-02-2011 So to execute a command you still go under the parent"Game"? Liek game.World.Elite.Body:Remove() RE: some scripting stuffs - Jacob__mybb_import1 - 04-03-2011 Yes, but all member functions (:Remove()) start with a lowercase letter. RE: some scripting stuffs - Qwertygiy - 04-03-2011 Like this. [lua] local players = game.Players:getChildren() --finds all players, which is kinda useless --right now since there can only be one. --BTW you need to make a Word Wrap for this, Jacob. for q = 1, #players do --I could just say players[1], but I'll stick to multiplayer format local e = create("Explosion") local body = players[q]:getChild("Body") --in case it's been removed already somehow e.Radius = 5 e.Parent = game.World e.Position = body.Position body.Velocity = Vec2D(0,100) --Fun to watch sleep(1) game:chat("You've been BEWMed", Color(0,0,0)) -- I might have that in wrong order end [/lua] |