Skip to content

Instantly share code, notes, and snippets.

@Ahosall
Created October 15, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ahosall/d9a5bbee0aa7487b4b7888745fb29782 to your computer and use it in GitHub Desktop.
Save Ahosall/d9a5bbee0aa7487b4b7888745fb29782 to your computer and use it in GitHub Desktop.
local button = script.Parent
local tycoon = script.Parent.Parent.Parent
local function getPlayer(part)
local character = part.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
return player
end
end
local function assignTycoon(player)
local playerValue = Instance.new('ObjectValue')
playerValue.Name = 'TycoonOwner'
playerValue.Value = tycoon
playerValue.Parent = player
return playerValue
end
local function Toque (part)
local player = getPlayer(part)
if player then
local tycoonOwned = player:FindFirstChild('TycoonOwner')
if not tycoonOwned then
assignTycoon(player)
button:Destroy()
end
end
end
button.Touched:Connect(Toque)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment