a ball that will change the color of the person when a person is hit and will explode after a time limit
How would I do this?
2 answers
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!
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.
3 comments
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!
while tutorials help learning some, it does not help with everything, it would have been best to explain it.
Tutorials explain stuff.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Oh by the way, this is not a request site, but I am a nice person. :)
You are a very nice person.