|
| 08 Aug 2014 08:21 PM |
I am attempting script a brick so that after a player touches it ten times it will explode,turn hot pink,and after ten seconds will turn back to medium stone grey.
Normally this would be easy. But there is a catch. I need it to be able to add sparkles to the players torso when (only when) the brick is hot pink. I am confused as of how to do this and still be able to use the ten second delay. I have been experimenting with wait(),functions,and while true do loops all day. I can't figure it out,but then I suppose i'm still a beginner scripter.
-Just a side question. Do explosions break scripts? Just wondering.
Any help would be very much appreciated!
Here is a script I have so far that I want to build onto and make possible the things I mentioned above:
i=0 script.Parent.Touched:connect(function(hit) plr=game.Players:GetPlayerFromCharacter(hit.Parent) if plr then i=i+1 if i==10 then x=Instance.new("Explosion",Workspace) x.Position=script.Parent.Position script.Parent.BrickColor=BrickColor.new("Hot pink") end end end) |
|
|
| Report Abuse |
|
|
ungh01
|
  |
| Joined: 24 Dec 2008 |
| Total Posts: 876 |
|
|
| 08 Aug 2014 08:25 PM |
Do you want it to explode every time after i>=10 ?
Also, do you want it to add sparkles when the explosion happens? If not, when do you want it to add sparkles? |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 08:30 PM |
| I want it to add sparkles when the brick is stepped on while it's hot pink. |
|
|
| Report Abuse |
|
|
ungh01
|
  |
| Joined: 24 Dec 2008 |
| Total Posts: 876 |
|
|
| 08 Aug 2014 08:31 PM |
| So basically when i is greater than 10? |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 08:34 PM |
I forgot that I need the variable i to reset to 0 after the explosion. My bad. I want it so that after you die by stepping on the brick ten times,the same is possible again. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 08:37 PM |
So basically I want it so that every time I step on this brick ten times it will explode,turn hot pink,and after ten seconds will turn back to medium stone grey. During the time when it is hot pink I need it to be able to add sparkles to the players torso when the brick is touched. (Only when it's touched when it's pink for ten seconds) |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 08:39 PM |
| That's why it's complex. :/ |
|
|
| Report Abuse |
|
|
ungh01
|
  |
| Joined: 24 Dec 2008 |
| Total Posts: 876 |
|
| |
|
| |
|
ungh01
|
  |
| Joined: 24 Dec 2008 |
| Total Posts: 876 |
|
|
| 08 Aug 2014 09:08 PM |
i=0 check=false
start=tick() en = tick() ten = false
script.Parent.Touched:connect(function(hit) plr=game.Players:GetPlayerFromCharacter(hit.Parent) if check then return end check=true if plr then if ten then en=tick() end print(i) if not ten then i=i+1 end if i==10 and not ten then ten=true start=tick() coroutine.resume(coroutine.create(function() wait(10) script.Parent.BrickColor=BrickColor.new("Medium grey") end)) x=Instance.new("Explosion",Workspace) x.Position=script.Parent.Position x.BlastPressure=0--just so i didn't die during testing script.Parent.BrickColor=BrickColor.new("Hot pink") end if (en-start)>10 then start=tick() i=0 ten=false end end wait(1) check=false end) |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2014 11:47 PM |
Works great. Thanks for your time and help. I really appreciate it. I do have one last problem though. During the time when it is hot pink I need it to be able to add sparkles to the players torso when the brick is touched. |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2014 01:00 AM |
You know what,nevermind. I keep losing my logic... I need to start thinking more clearly. Here is the script I wanted. And so I wrote it. I do thank you for trying to help me when I was in need though. I just simply was having a brain dead moment.
The perfectly working script:
i=0 script.Parent.Touched:connect(function(hit) plr=game.Players:GetPlayerFromCharacter(hit.Parent) if plr and script.Parent.BrickColor.Name=="Really blue" then s=Instance.new("Sparkles",hit.Parent.Torso) s.SparkleColor=BrickColor.new("Really blue").Color wait(20) for k=1,90000 do hit.Parent.Torso:FindFirstChild("Sparkles"):Remove() end elseif plr then i=i+1 print(i) end if i==10 then i=0 x=Instance.new("Explosion",Workspace) x.Position=script.Parent.Position x.BlastPressure=0 script.Parent.BrickColor=BrickColor.new("Really blue") wait(10) script.Parent.BrickColor=BrickColor.new("Institutional white") end end) |
|
|
| Report Abuse |
|
|