jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 01 Mar 2015 02:47 PM |
This is within a local script in the startergui, what it's supposed to do is any model named GoldModel will dissappear when touched, also it will add a point. The issue is when I start the game, the gold doesnt go into lighting when touched, nor does it give a point, however GoldDetector and GoldBase do turn transparent. Any help is appreciated!
c=game.Workspace:GetChildren() for _,v in pairs(c) do if v.Name=="GoldModel" then gm=v g=gm.Gold gd=gm.GoldDetector gb=gm.GoldBase gb.Transparency=1 gd.Transparency=1 end end
function onTouched(limb) local character = limb.Parent local player = game.Players:GetPlayerFromCharacter(character) player.leaderstats.Gold.Value=player.leaderstats.Gold.Value+1 gm.Parent=game.Lighting end
gd.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 02:51 PM |
c=game.Workspace:GetChildren() gd = nil
for _,v in pairs(c) do if v.Name=="GoldModel" then gm=v g=gm.Gold gd=gm.GoldDetector gb=gm.GoldBase gb.Transparency=1 gd.Transparency=1 end end
function onTouched(limb) if limb.Parent:findFirstChild("Humanoid") then local character = limb.Parent local player = game.Players:GetPlayerFromCharacter(character) player.leaderstats.Gold.Value=player.leaderstats.Gold.Value+1 gm.Parent=game.Lighting end end
gd.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
| |
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 01 Mar 2015 02:58 PM |
Wait, nvm... I forgot to mention there are multiple GoldModels, I want it to pick up all of them, but it only picks up the first one on the list. |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 03:01 PM |
| So you want to use one script and use the .Touched function on all of them? Im not understanding your issue. |
|
|
| Report Abuse |
|
|
jtefurd
|
  |
| Joined: 01 May 2010 |
| Total Posts: 952 |
|
|
| 01 Mar 2015 03:03 PM |
| That's exactly what I want to do lol |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 03:06 PM |
You only attach the event to one part. Insert your event connection into the loop, like this:
function onTouched(limb) local character = limb.Parent local player = game.Players:GetPlayerFromCharacter(character) player.leaderstats.Gold.Value=player.leaderstats.Gold.Value+1 gm.Parent=game.Lighting end
c=game.Workspace:GetChildren() for _,v in pairs(c) do if v.Name=="GoldModel" then local gm=v gm.GoldBase.Transparency=1 gd=gm.GoldDetector gd.Transparency=1 gd.Touched:connect(onTouched) end end |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 03:06 PM |
The model "GoldModel", does it have multiple gold called "Gold"? so like
-Gold Model --Gold --Gold --Gold --Gold --Gold --Gold |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2015 03:09 PM |
| Also, changing onTouched to what Xtreme posted is a good idea. You can't be sure that what is touching the gold is a character. |
|
|
| Report Abuse |
|
|