|
| 03 Feb 2015 09:39 AM |
ok so i have a problem, im working on a tycoon and i would like to know how i make the buttons so only the owner can buy things.
here is the script:
----------------------------------------------------------------------------------------------------------------------------- model = script.Parent.Parent.Parent.Drop Upgradecost = 0 -------------------------------------------------------------------------------------------------------------------------
upgradeStuff = model:clone()
model:remove()
local ting = 0 --debouncer
function onTouched(hit) if ting == 0 then --check for debounce ting = 1 --activate debounce local 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 |
|
|
eTempest
|
  |
| Joined: 23 Jul 2011 |
| Total Posts: 3704 |
|
|
| 03 Feb 2015 10:20 AM |
Hi i'm new to scripting but if your asking for a way to approach doing this I could help.
Some tycoons have bricks where you step on it to become the owner of the tycoon. When this occurs you could create a new stringvalue of the player's name in serverstorage (remember to remove it once the player leaves), and then in your script after "GetPlayerFromCharacter" it could check to see if the name is the same as the string value and perform the script.
Hope this is possible or helps in some way! |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 10:26 AM |
| This is a common button, but I'm not sure where to look because there's no output? Please tell me where the error is. |
|
|
| Report Abuse |
|
|
sdigeso
|
  |
| Joined: 13 Jun 2014 |
| Total Posts: 21 |
|
|
| 03 Feb 2015 10:29 AM |
Try and change this line local user = game.Players:GetPlayerFromCharacter(hit.Parent) --get player from touching human to
local user = game.Players:GetPlayerFromChracter[hit.Parent.Name] -- get player from touching human
That has worked for me when I am trying to get the user name. I also had to use the [] instead of () |
|
|
| Report Abuse |
|
|
|
| 03 Feb 2015 03:00 PM |
| What im asking is is there anyway to block other players from touching that button exept the tycoon owner, so basically other players cant pay upgrades for him |
|
|
| Report Abuse |
|
|
| |
|