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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Feb 2013 11:17 AM |
| Well It did it to me the first time but not the 2 |
|
|
| Report Abuse |
|
|