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

How would I do this? [closed]

Asked by 8 years ago

a ball that will change the color of the person when a person is hit and will explode after a time limit

Closed as Not Constructive by darkelementallord, rexbit, and M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
2
Answered by
IcyEvil 260 Moderation Voter
8 years ago

I will go step by step on how to do this.

Start with this

script.Parent.Touched:connect(function(hit)

end)

what I did is called an anonymous function and it is amazing so instead of you doing this.

function OnTouch(hit)

end
script.Parent.Touched:connect(hit)

after every single time you want to make that hit function(depending on what you are wanting of course...)

you can use the anonymous function and it will save you so much time.

Anyways this is the next step.

script.Parent.Touched:connect(function(hit)
if hit.Parent then
hit.BrickColor = BrickColor.random()
end
end)

that there checks to see if hit has a parent(everything has a parent so... gg) and then changes the part that was a hit to a random brickcolor.

now time for the explosion part :)

script.Parent.Touched:connect(function(hit)
if hit.Parent then
hit.BrickColor = BrickColor.random()
-- space for cleanliness :)
local explodeded = Instance.new("Explosion")
end
end)

this right here makes the variable "explodeded" the variable or whatever for the Explosion, it will create an explosion and is crucial to the script.

script.Parent.Touched:connect(function(hit)
if hit.Parent then
hit.BrickColor = BrickColor.random()
-- space for cleanliness :)
local explodeded = Instance.new("Explosion")
wait(5) 
explodeded.Parent = script.Parent
end
end)

that will end the script, with after 5 seconds of being touched it explodes( it does not destroy it I will add that to so you know just incase.)

script.Parent.Touched:connect(function(hit)
if hit.Parent then
hit.BrickColor = BrickColor.random()
-- space for cleanliness :)
local explodeded = Instance.new("Explosion")
wait(5) 
explodeded.Parent = script.Parent
wait(1.5)
script.Parent:Destroy()
end
end)

the above is incase you want it to destroy the ball, if not just ignore this portion and go with the one before this.

I hope I helped!

1
Oh by the way, this is not a request site, but I am a nice person. :) IcyEvil 260 — 8y
0
You are a very nice person. User#11440 120 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Like this,

script.Parent.Touched:connect(function(part)
    part.BrickColor = BrickColor.new("Really red")
    wait(10)
    local Boom = Instance.new("Explosion")
    Boom.Parent = game.Workspace
    Boom.Position = part
end)

make a sphere and put a script inside the ball and copy this into the script.

0
Also, I didn't mean to give you the answer without explaining how it works. You should watch some tutorials of roblox scripting! It's really awesome! User#11440 120 — 8y
0
while tutorials help learning some, it does not help with everything, it would have been best to explain it. IcyEvil 260 — 8y
0
Tutorials explain stuff. bosswalrus 84 — 8y