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
 

Help! Multiple owners = not good.

Previous Thread :: Next Thread 
Diddleshot is not online. Diddleshot
Joined: 13 May 2008
Total Posts: 676
20 Jul 2012 07:08 AM
This is a classic owner button script, which changes the name of the script's parent's parent, and the parent of that, due to there being two messages, but you don't need to worry about this.

The problem is once someone touches this button, they 'own' the office, and no other user can own the same office while they are in the game.

However.. This same person can then go on to own multiple offices, all with this same script in it. Pretty greedy.

How do I go about making the script check to see if they already own an office, and if so, not do anything/give a message that they already own one?
Any help would be much appreciated, thank you.




function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
script.Parent.Parent.Parent.Name = h.Parent.Name.. "'s Cubicle"
script.Parent.Parent.Name = ""
script.Parent.Transparency = 1
script.Parent.CanCollide = false
local player = game.Players:playerFromCharacter(h.Parent)
if player == nil then
script.Parent.Parent.Name = "Own this Cubicle"
script.Parent.Transparency = 0
script.Parent.Parent.Parent.Name = ""
script.Parent.CanCollide = true
else
print("The Owner Is Still In The Game")
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
20 Jul 2012 07:10 AM
One way to do it is to put an object into the Player object saying that the user already owns one.


function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")

local p = game.Players:GetPlayerFromCharacter(part.Parent)
if (not p) then return end
if (p:FindFirstChild("HasCubicle")) then return end

if h~=nil and p then

local has = Instance.new("ObjectValue",p)
has.Name = "HasCubicle"

script.Parent.Parent.Parent.Name = h.Parent.Name.. "'s Cubicle"
script.Parent.Parent.Name = ""
script.Parent.Transparency = 1
script.Parent.CanCollide = false
local player = game.Players:playerFromCharacter(h.Parent)
if player == nil then
script.Parent.Parent.Name = "Own this Cubicle"
script.Parent.Transparency = 0
script.Parent.Parent.Parent.Name = ""
script.Parent.CanCollide = true
else
print("The Owner Is Still In The Game")
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Diddleshot is not online. Diddleshot
Joined: 13 May 2008
Total Posts: 676
20 Jul 2012 07:14 AM
That's brilliant! Thank you for the help.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
20 Jul 2012 07:43 AM
Anytime :)
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