|
| 27 Sep 2011 07:11 PM |
So I made this tycoon button, but when I press it without enough money I get the message saying I don't have enough but then when I get enough and press it the button doesn't work. BUT, when I press the button with enough money the first time, the button works. LOLWUT? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ local upgrade = script.Parent.Upgrade.Value local cost = script.Parent.Cost.Value local button = script.Parent.Head local Models = script.Parent.Parent.Models local ownervl = script.Parent.Parent.OwnerName local debounce = false local moneyname = "Money" local newupgrade = Models[upgrade]:clone()
wait(.6) Models[upgrade]:remove()
button.Touched:connect(function(hit) if debounce then return end debounce = true if game.Players:playerFromCharacter(hit.Parent) and hit.Parent:findFirstChild("Humanoid") then plr = game.Players:playerFromCharacter(hit.Parent) if plr.Name == ownervl.Value then if plr:findFirstChild("leaderstats")[moneyname].Value >= cost then _G.Award(plr, "You have succesfully bought "..upgrade.."!") plr.leaderstats[moneyname].Value = plr.leaderstats[moneyname].Value - cost newupgrade.Parent = script.Parent.Parent.BoughtUpgrades newupgrade:MakeJoints() _G.Fade(button) elseif plr.leaderstats[moneyname].Value < cost then _G.Warn(plr, "You cannot afford this upgrade!") end elseif plr.Name ~= ownervl.Value then _G.Warn(plr, "You don't own this tycoon") wait(1) debounce = false end end end)
print(script.Parent.Upgrade.Value.." BuyButton loaded") |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 27 Sep 2011 08:10 PM |
'local upgrade = script.Parent.Upgrade.Value' 'local newupgrade = Models[upgrade]:clone()'
I hope you can see the error now, because I'm too lazy to actually help.
-The naked old man who is possibly chocolate... |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:10 PM |
| @Dan, upgrade may be a string value. |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:12 PM |
Doesn't string need like a " or ' before and after?
-The naked old man who is possibly chocolate... |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Sep 2011 08:18 PM |
Well, seeing that the script doesn't know it's string what I pointed out is why it errors.
-The naked old man who is possibly chocolate... |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:22 PM |
No, you don't need the " if it's already a string value.
Like this..
local plyr = workspace.darkkiller5555 workspace:findFirstChild(plyr.Name)
Note there are no ' or "'s in there but it'll still work. |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:23 PM |
Ah, my head was still derping from my nap.
-The naked old man who is possibly chocolate... |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:24 PM |
| It's fine chocolate old man. :3 |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2011 08:33 PM |
I revised it to what I originally wanted when I started scripting this, but still the same problem.
I'm thinking it might have something to do with the debounce... ~~~~~~~~~~~~~~~~~~~~~~~ local upgrade = script.Parent.Upgrade.Value local cost = script.Parent.Cost.Value local button = script.Parent.Head local Models = script.Parent.Parent.Models local ownervl = script.Parent.Parent.OwnerName local debounce = false local moneyname = "Money" local newupgrade = Models[upgrade]:clone()
wait(.6) Models[upgrade]:remove()
button.Touched:connect(function(hit) if debounce then return end debounce = true if game.Players:playerFromCharacter(hit.Parent) and hit.Parent:findFirstChild("Humanoid") then plr = game.Players:playerFromCharacter(hit.Parent) if plr.Name == ownervl.Value then if plr:findFirstChild("leaderstats")[moneyname].Value >= cost then _G.Award(plr, "You have succesfully bought "..upgrade.."!") plr.leaderstats[moneyname].Value = plr.leaderstats[moneyname].Value - cost newupgrade.Parent = script.Parent.Parent.BoughtUpgrades newupgrade:MakeJoints() _G.Fade(button) else needs = cost - plr.leaderstats[moneyname].Value _G.Warn(plr, "You need $"..needs.." more to buy this!") end end end end) wait(1) debounce = false
print(script.Parent.Upgrade.Value.." BuyButton loaded") |
|
|
| Report Abuse |
|
|
bibbs123
|
  |
| Joined: 03 Jun 2008 |
| Total Posts: 24994 |
|
|
| 27 Sep 2011 08:47 PM |
local upgrade = script.Parent.Upgrade.Value local cost = script.Parent.Cost.Value local button = script.Parent.Head local Models = script.Parent.Parent.Models local ownervl = script.Parent.Parent.OwnerName local debounce = false local moneyname = "Money" local newupgrade = Models[upgrade]:clone()
wait(.6) Models[upgrade]:remove()
button.Touched:connect(function(hit) if debounce then return end debounce = true if game.Players:playerFromCharacter(hit.Parent) and hit.Parent:findFirstChild("Humanoid") then plr = game.Players:playerFromCharacter(hit.Parent) if plr.Name == ownervl.Value then if plr:findFirstChild("leaderstats")[moneyname].Value >= cost then _G.Award(plr, "You have succesfully bought "..upgrade.."!") plr.leaderstats[moneyname].Value = plr.leaderstats[moneyname].Value - cost newupgrade.Parent = script.Parent.Parent.BoughtUpgrades newupgrade:MakeJoints() _G.Fade(button) elseif plr:findFirstChild("leaderstats")[moneyname].Value < cost then needs = cost - plr.leaderstats[moneyname].Value _G.Warn(plr, "You need $"..needs.." more to buy this!") else print("ERROR") end end end end) wait(1) debounce = false
print(script.Parent.Upgrade.Value.." BuyButton loaded")
I can't correct at night. If it says error, you made some mistake somewhere else. It /might/ work. I'm heading to bed now. Sorry if it won't work.
-It's not a victory until you have feasted upon their kidney. |
|
|
| Report Abuse |
|
|
Dresscode
|
  |
| Joined: 26 Aug 2010 |
| Total Posts: 151 |
|
|
| 28 Sep 2011 06:32 PM |
no output = no help
.:/!#sckum#!\:. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2011 06:33 PM |
@Dress
There is not output, if there were any I would have definately posted it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Sep 2011 06:51 PM |
Are your global functions in regular scripts or localscripts?
-[::ƧѡÎḾḠΰῩ::]- -[::Maker of stuff and breaker of combos::]- |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2011 06:52 PM |
| Regular scripts in the workspace. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2011 06:58 PM |
Try this:
button.Touched:connect(function(hit) if debounce then return end debounce = true if game.Players:playerFromCharacter(hit.Parent) and hit.Parent:findFirstChild("Humanoid") then plr = game.Players:playerFromCharacter(hit.Parent) if plr.Name == ownervl.Value then if plr:findFirstChild("leaderstats")[moneyname].Value >= cost then _G.Award(plr, "You have succesfully bought "..upgrade.."!") plr.leaderstats[moneyname].Value = plr.leaderstats[moneyname].Value - cost newupgrade.Parent = script.Parent.Parent.BoughtUpgrades newupgrade:MakeJoints() _G.Fade(button) end elseif plr.leaderstats[moneyname].Value < cost then _G.Warn(plr, "You cannot afford this upgrade!") elseif plr.Name ~= ownervl.Value then _G.Warn(plr, "You don't own this tycoon") wait(1) debounce = false end end end)
-[::ƧѡÎḾḠΰῩ::]- -[::Maker of stuff and breaker of combos::]- |
|
|
| Report Abuse |
|
|
| |
|
| |
|
bibbs123
|
  |
| Joined: 03 Jun 2008 |
| Total Posts: 24994 |
|
|
| 29 Sep 2011 06:26 PM |
local upgrade = script.Parent.Upgrade.Value local cost = script.Parent.Cost.Value local button = script.Parent.Head local Models = script.Parent.Parent.Models local ownervl = script.Parent.Parent.OwnerName local debounce = false local moneyname = "Money" local newupgrade = Models[upgrade]:clone()
wait(.6) Models[upgrade]:remove()
button.Touched:connect(function(hit) if debounce then return end debounce = true if game.Players:playerFromCharacter(hit.Parent) and hit.Parent:findFirstChild("Humanoid") then plr = game.Players:playerFromCharacter(hit.Parent) if plr.Name == ownervl.Value then if plr:findFirstChild("leaderstats")[moneyname].Value > (cost -1) then _G.Award(plr, "You have succesfully bought "..upgrade.."!") plr.leaderstats[moneyname].Value = plr.leaderstats[moneyname].Value - cost newupgrade.Parent = script.Parent.Parent.BoughtUpgrades newupgrade:MakeJoints() _G.Fade(button) elseif plr.leaderstats[moneyname].Value < cost then _G.Warn(plr, "You cannot afford this upgrade!") end elseif plr.Name ~= ownervl.Value then _G.Warn(plr, "You don't own this tycoon") wait(1) debounce = false end end end)
print(script.Parent.Upgrade.Value.." BuyButton loaded")
No idea. Best try.
-It's not a victory until you have feasted upon their kidney. |
|
|
| Report Abuse |
|
|