Problem with getting tycoon owner

  1. What do you want to achieve? Keep it simple and clear! So basically i’m making a tycoon. Button while activated should get owner name by self.Tycoon.Owner. I set self.Owner in Tycoon Module to player and for some reason i couldn’t activate this button

  2. What is the issue? Include screenshots / videos if possible! Described in 1st

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I was making it by youtube video and it should work

Setting Tycoon Owner Code:

Players.PlayerAdded:Connect(function(player)
	local tycoon = Tycoon.new(player)
	Tycoon:Init()
end)

Setting Tycoon Owner in Tycoon.Owner code:

function Tycoon.new(player)
	local self = setmetatable({}, Tycoon)
	self.Owner = player
	
	Tycoon._topicEvent = Instance.new("BindableEvent")
	return self
end

Getting Tycoon.Owner code:

function Button:Press(player)
	local id = self.Instance:GetAttribute("Id")
	local cost = self.Instance:GetAttribute("Cost")
	local cash = PlayerManager.GetMoney(player)
	
	if player == self.Tycoon.Owner and cash >= cost then -- here i getting it and it no work
		print("Player is owner and have enough money")
		PlayerManager.SetMoney(player, cash - cost)
		self.Tycoon:PublishTopic("Button", id)
		self.Instance:Destroy()
	end
end

isn’t Tycoon.Owner an object Value?
self.Tycoon.Owner.Value

image
No it’s not.

can you show me the module then?

Which one? I mentioned 2 modules and one server script

try to check if player.Name == self.Tycoon.Owner

It didn’t give any result. Also Player and Player Name give same “PhantomGame_Youtube” Tested it by print

i have to know what is self.Tycoon.Owner exactly is.

local CollectionService = game:GetService("CollectionService")
local template = game:GetService("ServerStorage").Template
local componentFolder = script.Parent.Components
local tycoonStorage = game:GetService("ServerStorage").TycoonStorage

local function NewModel(model, cframe)
	local newModel = model:Clone()
	newModel:PivotTo(cframe)
	newModel.Parent = workspace
	return newModel
end

local Tycoon = {}
Tycoon.__Index = Tycoon

function Tycoon.new(player)
	local self = setmetatable({}, Tycoon)
	self.Owner = player -- here is setting player
	
	Tycoon._topicEvent = Instance.new("BindableEvent")
	return self
end

function Tycoon:Init()
	self.Model = NewModel(template, CFrame.new(-238, 36.25, -165))
	
	self:LockAll()
end

function Tycoon:LockAll()
	for _, instance in ipairs(self.Model:GetDescendants()) do -- Here is error
		if CollectionService:HasTag(instance, "Unlockable") then
			self:Lock(instance)
		else
			self:AddComponents(instance)
		end
	end
end

function Tycoon:Lock(instance)
	instance.Parent = tycoonStorage
	self:CreateComponent(instance, componentFolder.Unlockable)
	
end

function Tycoon:Unlock(instance, id)
	CollectionService:RemoveTag(instance, "Unlockable")
	self:AddComponents(instance)
	instance.Parent = self.Model	
end

function Tycoon:AddComponents(instance)
	for _, tag in ipairs(CollectionService:GetTags(instance)) do
		local component = componentFolder:FindFirstChild(tag)
		if component then
			self:CreateComponent(instance, component)
		end
	end
end

function Tycoon:CreateComponent(instance, componentScript)
	local compModule =require(componentScript)
	local newComp = compModule.new(self, instance)
	newComp:Init()
end

function Tycoon:PublishTopic(topicName, ...)
 self._topicEvent:Fire(topicName, ...)	
end

function Tycoon:SubscribeTopic(topicName, callback)
	local connection = self._topicEvent.Event:Connect(function(name, ...)
		if name == topicName then
			callback(...)
		end
	end)
    return connection	
end

function Tycoon:Destroy()
	self.Model:Destroy()
	self._topicEvent:Destroy()
end

return Tycoon

Well i think this is module script you asked for

Player will return an instance for the player, but player.Name will return the player’s Name.

Well print same gives my nickname

Well i think it should work, syntax is right i think.

Well also printed self.Owner and it’s same my nickname.

Sorry for bump, reviving this topic cuz problem still not fixed.

Alright nvm, topic solved. For everyone who could have same error. Change self.Owner to Tycoon.Owner and it will work.

Hi,

I have a similar script here. I’m trying to get the “self.Tycoon.Owner” in another script that has click detectors in it. When I change “self.Owner” to “Tycoon.Owner”, it solves that issue, however creates a worse one. The new issue means anyone in the game can’t use their tycoon when someone new joins. The new joiner owns all tycoons.

I’m not entirely sure how best to get the tycoon owner in the script I’m using on the owner door. Anyone experienced a similar issue?