Tycoon Button Help

I am making a tycoon and I bought a tycoon Kit from another developer.
The Starting button will not spawn and the Person who I bought it off does not know why because it works perfectly fine in his game.
If you can help me out it would be much appreciated

1 Like

…

Can you please show us at least some code or screenshots or the structure of the gui, and the output?

We cant guess what the problem is.

2 Likes

i aint got a clue where the part of the script is but ill send the full script n the button model if that helps?

Is the button a prt or a gui object?

If you can find it, that would really help.

Also do you mind sharing the output (View → Output)?

local ReplicatedStorage = game.ReplicatedStorage
local Modules = ReplicatedStorage.Modules
local Datastore = require(Modules.DataStore) shared.Datastore = Datastore
local Droppers = require(Modules.DropperBeahvior)
local Settings = require(Modules.Globals)
local Owners = {}
local tycoons = workspace:WaitForChild(“Tycoon”).Tycoons:GetChildren()
local tempData = {}
local updateTime = 5
local buttonCount
local names = {}
for i,tycoon in pairs(tycoons) do --Put things in ReplicatedStorage, Setup Spawn, Hide Buttons
tycoon.Name = tycoon.Name… i
local SpawnPad = tycoon:WaitForChild(“SpawnLocation”)
local Models = tycoon.Models
Models.Parent = ReplicatedStorage
Models.Name = tycoon.Name
local Buttons = tycoon.Buttons:GetChildren()
if not buttonCount then
buttonCount = 0
for i, button in ipairs(Buttons) do
if not button.Config.Gamepass.Value and not button.Config:FindFirstChild(“Free”) then
buttonCount += 1
end
end
end
for i, button in ipairs(Buttons) do
for i,v in ipairs(button:GetDescendants()) do
if v:IsA(“BasePart”) then
v.Transparency = 1
v.CanCollide = false
end
if v:IsA(“Decal”) then
v.Transparency = 1
end
end
button.stuff.Income.Enabled = false
end
end

local function playerHasAutoCollector(player)
local gamepasses = Datastore:GetData(player).Gamepasses or {}
local gamepassId = require(game.ServerScriptService.Monetization.Passes[“Auto Collector”]).Id
return not not table.find(gamepasses, gamepassId)
end

local function addedChar(char, player)
local tycoon = Owners[player]
wait(.1)
if tycoon then
local SL = tycoon:WaitForChild(“SpawnLocation”)
char.HumanoidRootPart.CFrame = SL.CFrame * CFrame.new(0,5,0)
local dataType = “Pstat”
game.ReplicatedStorage.RE.changeStat:FireClient(player, dataType, Datastore.Cache[player][dataType])
dataType = “Sstat”
game.ReplicatedStorage.RE.changeStat:FireClient(player, dataType, Datastore.Cache[player][dataType])
else
print(player, “does not have a tycoon for added”)
end
end
local function claimTycoon(tycoon, player)
Owners[player] = tycoon
tycoon.Owner.Value = player.Name
coroutine.wrap(function()
local content, isReady = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
tycoon.SpawnLocation.Imager.ImageLabel.Image = content
tycoon.SpawnLocation.Namer.TextLabel.Text = player.Name
end)()
end
local function clearTycoon(tycoon)
for i,object in ipairs(tycoon.PurchasedObjects:GetChildren()) do
object:Destroy()
end
for i, button in ipairs(tycoon.Buttons:GetChildren()) do
button.Config.Owned.Value = false
end

tycoon.SpawnLocation.Imager.ImageLabel.Image = " "
tycoon.SpawnLocation.Namer.TextLabel.Text = " "
tycoon.Owner.Value = ""

end
local function chooseTycoon(player)
for i,v in pairs(tycoons) do --Choose Tycoon
if v.Owner.Value == “” then
claimTycoon(v, player)
return v
end
end

-- no tycoon available
for i,v in pairs(tycoons) do 
	if v.Owner.Value and not game.Players:FindFirstChild(v.Owner.Value) then
		clearTycoon(v)
		claimTycoon(v, player)
		return v
	end
end

end

local function changeStats(player, stat, alias)
player.leaderstats[alias].Value = Datastore.Cache[player][stat]
end
--------------------------Button Functions---------------------------------------------
local function isGamepassObject(tycoon, object)
return tycoon.Buttons[object.Name].Config.Gamepass.Value
end
local function scanButtons(player) --Button Load Functionality
local tycoon = Owners[player]
if tycoon then
local savedObjects = Datastore.Cache[player].Objects
for i,button in ipairs(tycoon.Buttons:GetChildren()) do
if not savedObjects[button.Name] == true then
local dependency = button.Config.Dependency.Value
local buttons = Datastore.Cache[player].buttons
if dependency and savedObjects[tostring(dependency.Name)] == true and button.Config.Owned.Value == false then
button.Config.Owned.Value = true
game.ReplicatedStorage.RE.Button:FireClient(player, button, true)
elseif not dependency and button.Config.Owned.Value == false then
button.Config.Owned.Value = true
game.ReplicatedStorage.RE.Button:FireClient(player, button, true)
end
end
end
else
warn(“No Tycoon Bug, Weird”)
end
end
local function Purchase(player, button, tycoon)
game.ReplicatedStorage.RE.Button:FireClient(player, button, false)
local PurchaseFolder = button.Parent.Parent.PurchasedObjects
local clone = ReplicatedStorage[tycoon.Name]:FindFirstChild(button.Name)
if button.Config:FindFirstChild(“Income”) then
tempData[player].income += button.Config.Income.Value
end
if clone then
spawn(function()
wait(Settings.BuildTime + 1)
clone:Clone().Parent = PurchaseFolder
end)
end
scanButtons(player)
end
local function loadTycoon(player, tycoon)
if Datastore.Cache[player] then
for i,v in pairs(Datastore.Cache[player].Objects) do
Purchase(player, tycoon.Buttons:WaitForChild(i), tycoon)
end
end
scanButtons(player)
end
game.ReplicatedStorage.RE.purchaseButton.OnServerInvoke = function(player, button)
local result = false
if button then
if player and Datastore.Cache[player].Pstat >= button.Config.Cost.Value then
Datastore.Cache[player].Pstat -= button.Config.Cost.Value
player.leaderstats.Money.Value = Datastore.Cache[player].Pstat
–if expendable Sstat, add a value that indicates currency type, and check it here
game.ReplicatedStorage.RE.changeStat:FireClient(player, “Pstat”, Datastore.Cache[player].Pstat)
Datastore.Cache[player].Objects[button.Name] = true
Purchase(player, button, Owners[player])
result = true
end
end
return result
end
game.ReplicatedStorage.RE.serverGamepassUpdate.Event:Connect(function(player, button)
Datastore.Cache[player].Objects[button.Name] = true
Purchase(player, button, Owners[player])
game.ReplicatedStorage.RE.gamepassUpdate:FireClient(player, button)
end)

local function collectMoney(player)
local PlrBalance = tempData[player].pool
if PlrBalance then
local money = PlrBalance
tempData[player].pool = 0
Datastore.Cache[player].Pstat += PlrBalance
player.leaderstats.Money.Value = Datastore.Cache[player].Pstat
game.ReplicatedStorage.RE.changeStat:FireClient(player, “Pstat”, Datastore.Cache[player].Pstat)
return money
end
end

game.ReplicatedStorage.RE.emptyCollector.OnServerInvoke = collectMoney
game.ReplicatedStorage.RE.serverChangeStat.Event:Connect(function(player, value)
Datastore.Cache[player].Pstat += value
player.leaderstats.Money.Value = Datastore.Cache[player].Pstat

game.ReplicatedStorage.RE.changeStat:FireClient(player, "Pstat", Datastore.Cache[player].Pstat)

end)

spawn(function()
while wait() do
for i,plr in ipairs(game.Players:GetPlayers()) do
if plr and Datastore.Cache[plr] and tempData[plr] then
spawn(function()
local bonus = (Datastore.Cache[plr].Rebirth * 0.5) * tempData[plr].income

				tempData[plr].pool += math.floor(tempData[plr].income + bonus + Settings.BaseIncome) * playerHasDoubleCash(plr)

				if playerHasAutoCollector(plr) then
					collectMoney(plr)
				end

				game.ReplicatedStorage.RE.updateCollector:FireClient(plr, tempData[plr].pool)
			end)
		end
	end
	wait(updateTime)
end

end)
--------------------------Data Functions---------------------------------------------
local function clone(tabl)
local data = {}

for index, value in pairs(tabl) do
	data[index] = (type(value) == "table" and clone(value)) or value
end

return data

end

game.Players.PlayerAdded:connect(function(player)
local DefaultData = {
Objects = {},
Gamepasses = {},
Pstat = 0,
Sstat = 0,
Rebirth = 0
}
local data = Datastore:GetData(player) or Datastore:SetData(player, clone(DefaultData))
if not data then
return player:Kick(“Could not Initiliaze”)
end

-- update data
for i, v in pairs(DefaultData) do
	if not data[i] then
		local value = v
		if type(v) == "function" then
			value = clone(v)
		end
		data[i] = value
	end
end

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local money = Instance.new("IntValue",leaderstats)
money.Name = "Money"
money.Value = data.Pstat

local rebirth = Instance.new("IntValue",leaderstats)
rebirth.Name = "Rebirth"
rebirth.Value = data.Rebirth

--changeStats(player, "Sstat", alias)
local tycoon = chooseTycoon(player)
if not tycoon then
	--return player:Kick("No Tycoon found. Please join another game.")	
	warn("NO TYCOON FOUND")
end

tempData[player] = {pool = 0, income = 0}  --Temp Data
loadTycoon(player, tycoon) --Load Player's Tycoon,Function
game.ReplicatedStorage.RE.InitializeClient:FireClient(player, tycoon)
if player.Character then
	local char = player.Character
	addedChar(char,player)
end
player.CharacterAdded:connect(function(char)		
	addedChar(char,player)
end)

end)
game.ReplicatedStorage.RE.addStat.Event:connect(function(plr,dataType, val)
Datastore.Cache[plr][dataType] += val
end)
local function checkRebirth(plr)
local tycoon = Owners[plr]
local unlocked = 0
for i, object in pairs(tycoon.PurchasedObjects:GetChildren()) do
if not isGamepassObject(tycoon, object) then
unlocked += 1
end
end

if unlocked >= buttonCount then
	return true, Datastore.Cache[plr].Rebirth 
else
	return false, Datastore.Cache[plr].Rebirth 
end

end
game.ReplicatedStorage.RE.checkRebirth.OnServerInvoke = function(plr)
return checkRebirth(plr)
end
game.ReplicatedStorage.RE.Rebirth.OnServerEvent:connect(function(plr)
local check = checkRebirth(plr)
local tycoon = Owners[plr]
print(plr, " rebirthed.")
if check == true then
Datastore.Cache[plr].Rebirth += 1
Datastore.Cache[plr].Pstat = 0
Datastore.Cache[plr].Sstat = 0

	plr.leaderstats.Money.Value = Datastore.Cache[plr].Pstat
	plr.leaderstats.Rebirth.Value = Datastore.Cache[plr].Rebirth

	for name in pairs(Datastore.Cache[plr].Objects) do
		local object = tycoon.PurchasedObjects:FindFirstChild(name)
		local button = tycoon.Buttons:FindFirstChild(name)

		if (object and button) and not isGamepassObject(tycoon, object) then
			Datastore.Cache[plr].Objects[name] = nil
			button.Config.Owned.Value = false
			object:Destroy()
		end
	end

	scanButtons(plr)

	tempData[plr].pool = 0
	tempData[plr].income = 0
	game.ReplicatedStorage.RE.changeStat:FireClient(plr, "Pstat", 0)
	game.ReplicatedStorage.RE.changeStat:FireClient(plr, "Sstat", 0)
	game.ReplicatedStorage.RE.updateCollector:FireClient(plr, tempData[plr].pool)
end

end)
game.Players.PlayerRemoving:Connect(function(plr)
local tycoon = Owners[plr] --Disown Tycoon
if not tycoon then
for i, model in pairs(game.Workspace.Tycoon.Tycoons:GetChildren()) do
if model.Owner.Value == plr.Name then
tycoon = model
end
end
end

if tycoon then
	Owners[plr] = nil
	clearTycoon(tycoon)
else
	warn(plr.Name, " is leaving with no tycoon.")
end
Datastore:SetData(plr)

end)

do
local function saveServerData()
for i, player in pairs(game.Players:GetPlayers()) do
coroutine.wrap(function()
Datastore:SetData(player)
end)()
end

	wait(5) -- yield
end

game:BindToClose(saveServerData)

while wait(60 * 5) do
	saveServerData()
end

end

Screenshot 2021-12-20 193930

How do i share the output. Sorry im new to all this.

Go to view then click on script analysis and output. (analysis may help you catch the bug)

I may know actually why it doesn’t put them there so you need to find all buttons and put them in StarterGui

to let you know, if you bought this you got scammed you could of gotten it for free its an uncopylocked game

1 Like

Just a tip, up on the output page you can put what messages you’d like to be displayed or undisplayed.

Oh right. oops oh well good job I did not pay loads then.

How much did you pay if you don’t mind me asking?

Anyways I guess you could just put them (GUI stuff) in the starter GUI and should work as fine

100 Robux witch dose not bother me i make 10X that in a day

ill give it a try. thanks. If it dosnt work can i add you to team create?

Also just a tip you should really familiarize yourself with a bit of knowledge in coding at least, and how to do stuff in the studio and to avoid being scammed you should always be careful about who you buy from and their reputation around the community before buying and getting scammed again.

1 Like

I’m good, don’t worry though I’ll be here until the problem is fixed :slight_smile:

Nah aint worked. If im best using that zeds tycoon kit for now ill use that n keep an eye out

Okay, stay safe and good luck!