|
| 26 Aug 2011 10:54 AM |
I'm a newb scripter so I would appreciate some help with fixing this :3
It's a tycoon-like buy button, but it broke when shot, so I added:
if hit ~= nil then if hit.Parent ~= nil then
Now however, it doesn't work at all...
Here's the full thing:
model = script.Parent.Parent.Parent.MyModelName --Change the last part to your upgrade-models name Upgradecost = 150 --Change cost to upgrade -------------------------------------------------------------------------------------------------------------------------
upgradeStuff = model:clone()--The thing that will be spawned when button is pushed --basically the "After"-part of the upgrade.. :P
model:remove() --remove the ingame model. We saved a clone for later.
local ting = 0 --debouncer
function onTouched(hit) if hit ~= nil then if hit.Parent ~= nil then if ting == 0 then --check for debounce ting = 1 --activate debounce
check = hit.Parent:FindFirstChild("Humanoid") --try to find the human that touched the button
if check ~= nil then --if toucher is a human then to following
local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human local stats = user:findFirstChild("leaderstats") --Find moneyholder
if stats ~= nil then --If moneyholder exists then local cash = stats:findFirstChild("Money") --Get money if cash.Value > (Upgradecost-1) then --If there is enough money then
cash.Value = cash.Value - Upgradecost --remove cash upgradeStuff.Parent = script.Parent.Parent.Parent --put the upgrade into the game script.Parent.Parent:remove() -- remove the upgrade button (in case of one-upgrade only)
end end end
ting = 0 --remove debounce end end
script.Parent.Touched:connect(onTouched) --start checking for touchers
|
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:16 AM |
NO ONE is going to "fix" this for you.
If you don't make your own scripts and encounter your own problems, you will never learn and you will just repeatedly come back here for help. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:19 AM |
I do make my own scripts... This is just one that I haven't made myself, as it is to complex for me... I am trying to edit it, and encountered a problem...
O.T.: You're from Ireland right? Me too, from Kildare, you? :3 |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:20 AM |
When you add an if statement remember to add the end.
~ Mitch ~ |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:22 AM |
Uhh sorry, I don't give out the location of my dwelling.
-Meath |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:24 AM |
@Mitch, oh my God, I feel like such an idiot now... Thank you for poitning that out :3
@Mario, lol, an maith leat caca? :P |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:33 AM |
| Níl, is maith liom cáca milis. Agus a ghlacadh as ar an "a" as le caca as Gaeilge focal agus féach cad a fhaigheann tú. : 3 |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:35 AM |
... *Backs away* Ehhh... ... I'm gunna take a wild guess and say your are older than me... I'm in second year...Going into third on Monday :( |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:38 AM |
| I'm in second year...Going into third on Tuesday XD |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2011 11:41 AM |
| Me too I guess, school starts on Tuesday but we go iin on Monday to get our st00f ready... |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 26 Aug 2011 12:10 PM |
| I'm turning Year 8 on Tuesday.. |
|
|
| Report Abuse |
|
|