!~OBJECTION234~!
Some persons say the wiki wont help them (Looks at aidanfisher). The wiki is great to learn scripts, the absolute begginer guide to script is the best guide in ROBLOX, but im making a guide cause im mad. So lets get started.
GETTING STARTED
First go to ROBLOX studio. Go to View > Toolbars > Command. Then go to View > Output.
Ok, we are ready to make the first script.
OUR FIRST SCRIPT
There are two ways to kill a humanoid. Deleting his head or his Torso or setting his life to 0. So here is our command:
I want to delete objection234's head.
Of course, the computer wont understand us, so lets mae it a script.
game --Lets search in game
You noticed the "--"? The one line comments are started with a "--".
game.Workspace --In the game, the Workspace
game.Workspace.objection234 --In the game, the workspace, search for objection234
game.Workspace.objection234.Head
Looks for my head. Ok now the computer knows wheres my head but it dont knows what to do with it. So lets tell the computer to use a FUNCTION. There are 2 kind of functions, Global and local. The function we are going to use is global.
game.Workspace.objection234.Head:Remove()
Done, this will remove our head. Of course it will not find objection234 if objectionb234 does not exist, so the Output will issue an error, something like "objection234 is not a valid member of a workspace" so lets find your name:
game.Workspace.YourNameHere.Head:Remove()
ROBLOX made the workspace a special item, so we can use
game.workspace
or
workspace
The workspace is the only object that allows us to do this.
SETTING VALUES
What about actually changing the value of an object, as opposed to removing an object? Earlier it was mentioned that there were two ways to kill someone. The more complicated way is setting one's Health to 0. The Health is contained in a Humanoid object (Humanoid.Health), which is contained within the character (game.Workspace.Player).
Example:
game.Workspace.objection234.Humanoid.Health --This will find objection234 health
But now we need to set it.
game.Workspace.objection234.Humanoid.Health = 0
That will assing 0 to the health value.
HOW TO INSERT A SCRIPT IN YOUR PLACE
Go to roblox studio > tools > inert > object > script
EDITING THE SCRIPT
NOTE: Go to edit mode, not play solo or build.
Click in the script and look at inside it. You will find a basic lua program.
print("Hello world")
What does print() do? It prints the contents in the Output bar.
To run the script just search the button "Play".
BASIC THINGs IN A SCRIPT
Creating the Script
Tagging Objects
The Listening Event
The Function
Modifying Objects/Tags
First we created our script so we are going to edit it. First ill show you how to make a tag:
tag = --Makes a tag named "tag"
tag = 90 --Sets the value of tag to 90
print(tag)
Will result in
90
Tags can tag objects too:
Objection = game.Workspace.objection234
Will make a tag named Objection and will set it value to game.Workspace.objection234
So, first delete the line print("Hello world") and put that tag.
Im going to teach you how to make it invisible.
brick = game.Workspace.Brick
Search a object called Brick and gives it the tag brick
LISTENING EVENT
Now we're getting into the meat of scripting. Sure, the script knows where the brick is, but that's all. It can't do anything else. Now we're jumping into a listening event.
A listening event is the trigger of the script. This is going to tell the script to do something if the listener finds the trigger fired. This is one important part of the script, otherwise you couldn't really make scripts wait for anything.
You still should have the script with the tag in it. We're going to make the script listen for being touched. Here's an example:
brick.Touched:connect(functionName) --When the brick its touched, connects a function
THE FUNCTION
Your script is getting better and better, but where is the function? Your script will break if it doesn't have one of those for the listener to refer the script to.
What is a function? It is where all your modifying work will be done. It is also an important part to your scripting. Without it, you could not make the script modify objects from listeners.
function onTouch(hit)
end
"function" is a special word, it cant be used as a name, same as end. There are 2 ways to wrtie a function:
function DoSomething()
end
rather than
DoSomething = function().
Lets go again to the onTouch() function:
function onTouch(hit)
end
Notice after "onTouch". This is the tag of the object that the listener found that touched the brick. This is not always needed, especially for different listeners. Most times, with other listening types unlike touching listeners, you would just place this:
function onTouch()
end
Modyfing objects, tags
Ok, the computer knows when make the function, weres the brick, but it dosent know what to do with it. So lets modify the brick tags
brick.Transparency = 1
wait(2)
brick.Transparency = 0
First it sets the brick transparency to 1 (Max transparency) and then waits 2 seconds, then sets the brick tarnsparency to 0 (No transparency).
THE COMPLETE SCRIPT
At last, this is the end of our script:
brick = game.Workspace.Brick --Sets the tag brick
function onTouch(hit) --Function onTouch()
brick.Transparency = 1 --Makes it transparent
wait(2) --Waits 2 seconds
brick.Transparency = 0 --Sets it transprency to 0
end --end the function
brick.Touched:connect(onTouch) --When it should fire the function
Done. Heres a well done reference page made by MrDooBringer, its about the functions:
http://wiki.roblox.com/index.php/Class_reference.
See you next time guys! Phew... Done
!~OBJECTION234~!
sábado, 6 de junio de 2009
Suscribirse a:
Entradas (Atom)