Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 07:54 AM |
script.Parent.Touched:connect(function(hit) pig = 0 if pig == 0 then game.StarterGui.Coin.TextButton.Text = pig pig = pig + 1 else pig = pig + 1 end end)
|
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 07:55 AM |
Because you need the PlayerGui, not the StarterGui. Some sort of:
script.Parent.Touched:connect(function(hit) pig = 0 if pig == 0 then game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text = pig pig = pig + 1 else pig = pig + 1 end end)
|
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 07:58 AM |
| it still doesnt work the text stays as 0 when i walk on the brick |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:00 AM |
pig = 0
script.Parent.Touched:connect(function(hit) if pig == 0 then game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text = pig pig = pig + 1 else pig = pig + 1 end end)
|
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
| |
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:04 AM |
I will explain what SHOULD happen.
script.Parent.Touched:connect(function(hit) --A player touched the brick pig = 0 --Pig goes to 0 if pig == 0 then --This will always be true, since the line before will be work everytime the brick gets touched. game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text = pig --The Text there changes to pig (which is 0) pig = pig + 1 --pig recieves + 1 but will be put back to 0 until the brick gets touched again else --if pig wouldn't be 0 (will never happen) pig = pig + 1 --pig recieves + 1 but will be put back to 0 until the brick gets touched again end --end of the if statement end) --end of the function
|
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:04 AM |
| do you know how to fix it? or a different script that would do the same thing? i cant seem to get it working when the script looks fine |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:05 AM |
Here's something I thought will be better:
script.Parent.Touched:connect(function(hit) pig = 0 if pig == 0 then game.Players:GetPlayerFromCharacter pig = pig + 1 (hit.Parent).PlayerGui.Coin.TextButton.Text = pig else pig = pig + 1 --What is that for? It will be changed back to 0 anyways. end end)
|
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:05 AM |
| ok i see i posted above before i saw that |
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:10 AM |
| what do i do to get it working then? |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:11 AM |
-.-
I already posted it.
script.Parent.Touched:connect(function(hit) pig = 0 if pig == 0 then game.Players:GetPlayerFromCharacter pig = pig + 1 (hit.Parent).PlayerGui.Coin.TextButton.Text = pig else pig = pig + 1 --What is that for? It will be changed back to 0 anyways. end end)
|
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:14 AM |
when i run that script it says it wont work Workspace.Part.Script:5: function arguments expected near 'pig' |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2012 08:16 AM |
| It needs to be "pig" not pig. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:16 AM |
Whoopsy, wrong "Enter" pressed.
script.Parent.Touched:connect(function(hit) pig = 0 if pig == 0 then pig = pig + 1 game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text = pig else pig = pig + 1 --What is that for? It will be changed back to 0 anyways. end end)
|
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:16 AM |
| No it mustn't. I just accidently pressed Enter at the wrong place. |
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:17 AM |
| im making a count so every time you walk on the brick it goes up one on the guis text but it doesnt seem very happy about that idear and i have to do it through a variable if it isnt a string |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2012 08:18 AM |
| Wait does it need to return "pig" or the value of pig? |
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:18 AM |
| and i dont know how to get around that without resetting it too 0 every time |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:19 AM |
script.Parent.Touched:connect(function(hit) game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Coin.TextButton.Text + 1
That's what you're looking for. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 13 Jun 2012 08:20 AM |
| Hmm wait, maybe you should make a while loop so it will change the text to a value and you should add that + 1 to the value, not the text. I think it won't work for the text. |
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
|
| 13 Jun 2012 08:21 AM |
| how do you change the text to a value? thats what i want too do |
|
|
| Report Abuse |
|
|
Gooslime
|
  |
| Joined: 07 Jan 2012 |
| Total Posts: 102 |
|
| |
|