|
| 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 |
|
|
| 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 |
|
|
| 20 Jul 2012 07:14 AM |
| That's brilliant! Thank you for the help. |
|
|
| Report Abuse |
|
| |