The stupidest script ever to be made. - 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: The stupidest script ever to be made. (/showthread.php?tid=7706) |
The stupidest script ever to be made. - Sazaho - 08-04-2011 Okay. So here is my script, obviously it doesn't work, because of my lack of scripting knowledge, and I was wondering what is missing. The script is a script to change the player's layer by pressing q and e. print("Yo, yo, yo. Whazzup mah homiiieeeess!!") P = Player.Layer Function Keydown (q) P = P +1 Function Keydown (e) P = P -1 RE: The stupidest script ever to be made. - Qwertygiy - 08-04-2011 Well, you need to define Player. And you need ends on functions. And you need link(event, function). And of course you can't have a layer of -1 or of 3. Here's how I would code this script, inside a tool. Oh yeah and [ lua ] tags FTW! [lua] local tool = script.Parent -- creating a variable local player = tool.Parent.Parent -- creating a variable from a variable local character = player.Character local layer = character:getChild("Body").Layer local minimum = 0 --you can't have a layer of -1 local maximum = 2 --you can't have a layer of 3 --That's all the variables. print("Variables loaded!") function RaiseLayer() if layer < maximum then --if the character's layer is below 2 then layer = layer + 1 else --if the layer is 2 then print("You are on the highest layer already.") end end --Always remember the ends for "do"s, "if"s, and "function"s. function LowerLayer() if layer > minimum then --if the layer is above 0 then layer = layer - 1 else --if the layer is 0 then print("You are on the lowest layer already.") end end function KeyPressed(key) --This function contains a variable in itself. if string.lower(key) == "q" then --Works with caps on RaiseLayer() --Calls this function elseif string.lower(key) == "e" then LowerLayer() --Calls that function end end print("Functions loaded!") link(tool.KeyDown, KeyPressed) --Links the tool being keypressed with the function [/lua] RE: The stupidest script ever to be made. - Glome - 08-04-2011 [lua] game.World:remove(); [/lua] Put that in your game than play it. RE: The stupidest script ever to be made. - tomi123456789 - 08-06-2011 whats the script? RE: The stupidest script ever to be made. - Assassin - 08-06-2011 Lol better than mine a lot of times. RE: The stupidest script ever to be made. - Duck - 08-07-2011 I already made a script to do this :3 But anyway You need to put some function ends You need to call the functions And you need to actually check the keydown to see what key was pressed And you need to define player |