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: Error in tycoon script! Help please!

Previous Thread :: Next Thread 
JohnMS is not online. JohnMS
Joined: 24 Aug 2006
Total Posts: 21864
06 Feb 2013 04:31 PM
Hey guys, I'm a total noob at scripting and I was given this button by a friend.

It doesn't work online at all. When stepped on it should display "Insufficient funds", "Not owner", or "upgrade complete!". It does absolutely nothing. I used output, and pressed play, and on every single upgrade it says "Attempt to index local 'upgrade' (a nil value) (line 6)


Here is the script. If you can help me out you will have fixed my place. Thanks!

local tycoon = script.Parent.Parent.Parent
local owner = tycoon.Owner
local debounce = false
local cost = 65 -- change 50 to the price you want the upgrade to cost
local upgrade = tycoon:findFirstChild("Test8") -- put the EXACT name of the upgrade
local newUpgrade = upgrade:Clone()
wait(.1)
upgrade:Remove()

script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil and debounce == false then
local alert = player.PlayerGui.TycoonGui.Alert
debounce = true
if owner.Value ~= player.Name then
alert.Text = "You are not the owner of this tycoon!" -- you can change "tycoon" to whatever you want
alert.Type.Value = "Alert" -- don't mess with this
alert.On.Value = true
wait(2) -- you can change the wait time to allow to be touched again
debounce = false
return end
if player.leaderstats.Money.Value < cost then
local mn = cost-player.leaderstats.Money.Value
alert.Text = "Insufficient funds! You need $" ..mn.. " more!"
alert.Type.Value = "Alert"
alert.On.Value = true
wait(2) -- you can change the wait time to allow to be touched again
debounce = false
return end
player.leaderstats.Money.Value = player.leaderstats.Money.Value - cost
newUpgrade.Parent = tycoon
alert.Text = "Upgrade complete!" -- you can change what it says here. For an example, you're buying a chair. Chair bought!
alert.Type.Value = "Message" -- don't mess with this
alert.On.Value = true
for i = 0.4, 1, 0.01 do
wait()
script.Parent.Transparency = i
end
script.Parent.Parent:Remove()
end
wait(2) -- you can change the wait time to allow to be touched again
debounce = false
end)
Report Abuse
777MrEpic is not online. 777MrEpic
Joined: 17 Oct 2012
Total Posts: 3998
06 Feb 2013 04:34 PM
Maybe something simple.
>Noob at scripting
More like Advanced.
I saw upgrade:Remove()
Did you declare where it was back in script?
I am sure I didn't fix anything I an a major fail at everything.
Report Abuse
JohnMS is not online. JohnMS
Joined: 24 Aug 2006
Total Posts: 21864
06 Feb 2013 04:35 PM
>777

I know absolutely nothing about what I posted.

Please explain more. :c
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
06 Feb 2013 04:41 PM
local upgrade = tycoon:findFirstChild("Test8") -- put the EXACT name of the upgrade

'Test8' doesn't exist.

~~Intermediate Scripter
Report Abuse
JohnMS is not online. JohnMS
Joined: 24 Aug 2006
Total Posts: 21864
06 Feb 2013 04:42 PM
I tested it by placing a brick named "Test8" in lighting.

It still does nothing.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
06 Feb 2013 04:43 PM
"local tycoon = script.Parent.Parent.Parent"

Where is 'tycoon' located and what is inside of it?

~~Intermediate Scripter
Report Abuse
Gagesellers is not online. Gagesellers
Joined: 11 Apr 2010
Total Posts: 19
22 Feb 2013 11:17 AM
Well It did it to me the first time but not the 2
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