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 » Scripters
Home Search
 

Re: Tycoon buttons

Previous Thread :: Next Thread 
antoineminer is not online. antoineminer
Joined: 14 Sep 2012
Total Posts: 4
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 is not online. 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
iwishforpie1 is not online. iwishforpie1
Joined: 20 Mar 2011
Total Posts: 1423
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 is not online. 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
antoineminer is not online. antoineminer
Joined: 14 Sep 2012
Total Posts: 4
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
antoineminer is not online. antoineminer
Joined: 14 Sep 2012
Total Posts: 4
03 Feb 2015 05:46 PM
anyone?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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