Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can we know how to do the exact script that we need to have? [closed]

Asked by
DjMusa2 81
6 years ago

Hello, I know maybe this question is like...unnecessary but J just wanted to know...How can we know the script, like the EXACT script, for example...

Make a kill brick

How will.I know the script??

Here is my try...

Parent.Parent.killplayer1touch
End)
0
Thank you! DjMusa2 81 — 6y
1
"parent.Parent.killplayer1touch" ok thats cool. Mr_Unlucky 1085 — 6y
1
WOAHHHHHHHHHHHHHHHHHHHHHHHHHHH DJ MUSA, I got u dude, ill help you on everything greatneil80 2647 — 6y
0
Lol thanks great. DjMusa2 81 — 6y

Locked by User#24403

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
2
Answered by
RAYAN1565 691 Moderation Voter
6 years ago
Edited 6 years ago

Don't expect to know how to script in just under a week. With all things, scripting takes time to master. However, don't feel overwhelmed because all scripters were in your exact position now. I even asked a similar question to this when I first wanted to learn how to script. In other words, no one is born already knowing how to script.

With that said, here is how I became sufficiently proficient in scripting:

  1. I read the basics of scripting from here: http://wiki.roblox.com/index.php?title=Scripting_Book/Contents. I opened Roblox studio and practiced what this website taught me and I encourage you to do the same. Don't do it all at once though. Take it one step at a time so you don't overwhelm yourself.

  2. If I had questions or struggled, I'd post my question along with my script on here and learn from my mistakes.

  3. I used Roblox wiki as a reference as I script. For example, if I'm writing a script and wanted to use a function such as math.random() but forgot what it does, I'd simply search on Google the following: "roblox wiki math.random" and find the webpage for it. Try this right now.

  4. Repeat steps 1-3 and keep practicing! You'll get it eventually, I promise.

  5. When you've become comfortable with scripting, go through this site and try to attempt answering questions.

  6. If you don't know the answer to someone's question, use your resources: Roblox wiki, your mind to think of a creative solution, Roblox studio to play around and test things out. I teach myself and the asker once I figure out a solution to their question(s). This helps expand my knowledge on scripting.

By the way, this is how you make a script that will ultimately kill your player once they touch the script's parent (or the object that the script is placed under):

function thisIsAFunction(characterBodyPart) --I'm just creating a function and naming it whatever I want. Inside the parenthesis is the subject of the function (which is the character's arm or leg that touches the object).
     local thisIsJustAName = characterBodyPart.Parent --I want the whole character though, not just the body part. I'm indexing this under the name of 'thisIsJustAName' (I could name it whatever I want).
     local humanoid = thisIsJustAName.Humanoid --I'm indexing again. I want to access the health of the character, which is located under humanoid. Remember thisIsJustAName is a shortcut for 'characterBodyPart.Parent'.
     humanoid.Health = 0 --Setting the health equal to 0. The player will die.
end --After every function, you place an 'end' so the computer knows when the function ends. Otherwise, the computer will get confused!

script.Parent.Touched:Connect(thisIsAFunction) --'script.Parent' is the object (or brick/part/etc.). 'Touched' is a special term in scripting, this is called an Event. ':Connect(thisIsAFunction)' will connect the event to the function I just wrote. Basically, every time the object is Touched, the computer will connect to my function and run the code that is written inside it.


Your final script is (without the comments):

function myFunction(characterBodyPart)
    local humanoid = characterBodyPart.Parent.Humanoid
    humanoid.Health = 0
end

script.Parent.Touched:Connect(myFunction)

I hope you learned something! Also, once you accumulate more scripting knowledge, you will begin to write the above script in a better, more efficient way. This script is written in a way as to ease you into scripting. Good luck! :-)

Ad
Log in to vote
1
Answered by 6 years ago

this:

script.Parent.Touched:Connect(function(part)
    if part.ClassName == "Part" then
        part.Parent:WaitForChild("Humanoid").Health = 0
    end
end

This is what happens: Part is touched then Class Name is defined to stop from confusion when touching hats within parts.... then Change the humanoids health to zero aka kill person.

Log in to vote
0
Answered by
Ince_FS 13
6 years ago

You can learned by looking at each function, use them, read them, and you'll learn, it's not that difficult.

0
learn* Ince_FS 13 — 6y
0
I don't no really understand, can you explain a little bit more please? DjMusa2 81 — 6y
0
Okay, the thing is to learn each function, what it is for, what it can be used for, how to combine it. I recommend you look at the Wiki so you learn. Ince_FS 13 — 6y
Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
6 years ago

Look at the roblox wiki. The roblox wiki cookbook and plenty of other articles on there will help you. Click here to enter the roblox wiki! Click here to enter the roblox wiki's cookbook.