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!

Previous Thread :: Next Thread 
Wolfydaisy is not online. Wolfydaisy
Joined: 01 Jul 2010
Total Posts: 927
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 is not online. 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 is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
11 Jul 2012 03:55 PM
Or...
game.Lighting["Gravity coil"]:clone()
Report Abuse
Wolfydaisy is not online. Wolfydaisy
Joined: 01 Jul 2010
Total Posts: 927
11 Jul 2012 03:55 PM
Okay I will try it!
Report Abuse
HatModder is not online. 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
Wolfydaisy is not online. Wolfydaisy
Joined: 01 Jul 2010
Total Posts: 927
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 is not online. 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
Wolfydaisy is not online. Wolfydaisy
Joined: 01 Jul 2010
Total Posts: 927
11 Jul 2012 04:02 PM
The Leaderboard has 'Coins' So do I need to change it to Coins?
Report Abuse
HatModder is not online. 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
Wolfydaisy is not online. Wolfydaisy
Joined: 01 Jul 2010
Total Posts: 927
11 Jul 2012 04:06 PM
Okay. Thanks!
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