generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: help me why wont it work

Previous Thread :: Next Thread 
Gooslime is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Cheater
Joined: 29 Jun 2007
Total Posts: 5258
13 Jun 2012 08:01 AM
^--- Forget that.
Report Abuse
Cheater is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
13 Jun 2012 08:16 AM
It needs to be "pig" not pig.
Report Abuse
Cheater is not online. 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 is not online. 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 is not online. 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
SilverNinja14 is not online. SilverNinja14
Joined: 16 Mar 2010
Total Posts: 1038
13 Jun 2012 08:18 AM
Wait does it need to return "pig" or the value of pig?
Report Abuse
Gooslime is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Gooslime
Joined: 07 Jan 2012
Total Posts: 102
13 Jun 2012 08:28 AM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image