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: Why is this happening?

Previous Thread :: Next Thread 
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
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
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
27 Sep 2011 07:30 PM
bump
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
27 Sep 2011 07:44 PM
bump
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
27 Sep 2011 08:08 PM
bump
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 Sep 2011 08:09 PM
No output?
Report Abuse
Danster5oo is not online. Danster5oo
Joined: 27 Aug 2010
Total Posts: 10003
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
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 Sep 2011 08:10 PM
@Dan, upgrade may be a string value.
Report Abuse
Danster5oo is not online. Danster5oo
Joined: 27 Aug 2010
Total Posts: 10003
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
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
27 Sep 2011 08:14 PM
It's a string value.
Report Abuse
Danster5oo is not online. Danster5oo
Joined: 27 Aug 2010
Total Posts: 10003
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
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
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
Danster5oo is not online. Danster5oo
Joined: 27 Aug 2010
Total Posts: 10003
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
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 Sep 2011 08:24 PM
It's fine chocolate old man. :3
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
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 is not online. 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 is not online. Dresscode
Joined: 26 Aug 2010
Total Posts: 151
28 Sep 2011 06:32 PM
no output = no help

.:/!#sckum#!\:.
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
28 Sep 2011 06:33 PM
@Dress


There is not output, if there were any I would have definately posted it.
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
28 Sep 2011 06:47 PM
Bump.
Report Abuse
DihydrogenOxide is not online. DihydrogenOxide
Joined: 20 Feb 2011
Total Posts: 642
28 Sep 2011 06:51 PM
Are your global functions in regular scripts or localscripts?

-[::ƧѡÎḾḠΰῩ::]-
-[::Maker of stuff and breaker of combos::]-
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
28 Sep 2011 06:52 PM
Regular scripts in the workspace.
Report Abuse
DihydrogenOxide is not online. DihydrogenOxide
Joined: 20 Feb 2011
Total Posts: 642
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
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
28 Sep 2011 07:20 PM
Still doesn't work D:
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
29 Sep 2011 04:27 PM
Bump.
Report Abuse
bibbs123 is not online. 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
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