|
| 11 Jul 2012 03:50 PM |
Can someone help me? I tried making GUI Shop for my minigame place and I Have the GUI But the script doesnt work? I will show you the one I made for the Gravity Coil. Yes I can see the GUI But it doesnt work when you try to buy it.
print("Shop Script Loaded")
Door = script.Parent local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Coins") if sp == nil then return false end if (sp.Value >=500) then sp.Value = sp.Value - 500 print("Enough Coins") game.Lighting.Gravity coil:clone().Parent = Buy Gravity Coil Door.BrickColor = BrickColor.new(21) wait(2) Door.BrickColor = BrickColor.new(37) debounce = false else debounce = false end end
end
connection = Door.Touched:connect(onTouched) --
I am new to scripting. |
|
|
| Report Abuse |
|
|
HatModder
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 12891 |
|
|
| 11 Jul 2012 03:54 PM |
"game.Lighting.Gravity coil:clone().Parent = Buy Gravity Coil" "GravityCoil", It shouldn't have a space, it would result in a error. And the name of the gravitycoil must be the exact same as the name in the script. Or else it won't work. Lua doesn't really like spaces, but you could also try "_" For spaces |
|
|
| Report Abuse |
|
|
WhiteRain
|
  |
| Joined: 24 Apr 2010 |
| Total Posts: 2723 |
|
|
| 11 Jul 2012 03:55 PM |
Or... game.Lighting["Gravity coil"]:clone() |
|
|
| Report Abuse |
|
|
| |
|
HatModder
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 12891 |
|
|
| 11 Jul 2012 03:56 PM |
| But either way, that is most likely your error in that script. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2012 03:57 PM |
Does this look right?
print("Shop Script Loaded")
Door = script.Parent local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Coins") if sp == nil then return false end if (sp.Value >=500) then sp.Value = sp.Value - 500 print("Enough Coins") game.Lighting.GravityCoil:clone().Parent = Buy GravityCoil Door.BrickColor = BrickColor.new(21) wait(2) Door.BrickColor = BrickColor.new(37) debounce = false else debounce = false end end
end
connection = Door.Touched:connect(onTouched) -- |
|
|
| Report Abuse |
|
|
HatModder
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 12891 |
|
|
| 11 Jul 2012 04:00 PM |
You forgot the apostrophes
print("Shop Script Loaded")
Door = script.Parent local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end function onTouched(hit) if debounce == false then local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = getPlayer(human) debounce = true if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Coins") if sp == nil then return false end if (sp.Value >=500) then sp.Value = sp.Value - 500 print("Enough Coins") game.Lighting."GravityCoil":clone().Parent = Buy GravityCoil Door.BrickColor = BrickColor.new(21) wait(2) Door.BrickColor = BrickColor.new(37) debounce = false else debounce = false end end
end
connection = Door.Touched:connect(onTouched) --
The gravitycoil must be the name of "GravityCoil" exactly like that in lighting. And there must be a leaderboard with the value of "Coin" |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2012 04:02 PM |
| The Leaderboard has 'Coins' So do I need to change it to Coins? |
|
|
| Report Abuse |
|
|
HatModder
|
  |
| Joined: 05 Jun 2012 |
| Total Posts: 12891 |
|
|
| 11 Jul 2012 04:04 PM |
| Yes, that must be the exact name of it, Otherwise it would most likely result in yet another error |
|
|
| Report Abuse |
|
|
| |
|