Problem making a tycoon

Hello developers, i’m trying to make a tycoon game. and i have a problem which is that when i touch a button to buy a dropper, it works, but when i touch the button in another tycoon, that dropper appears in the other tycoon. and i don’t want that.

i’m using GamerM8 method of making tycoons but a little bit different.

this is the MainScript code:

-- // Variables \\ --

local Tycoon = script.Parent.Parent

local BoughtItems = Tycoon:FindFirstChild("BoughtItems")
local Buttons = Tycoon:FindFirstChild("Buttons")
local DropperParts = Tycoon:FindFirstChild("DropperParts")
local Base = Tycoon:FindFirstChild("Base")
local Values = Tycoon:FindFirstChild("Values")
local Items = Tycoon:FindFirstChild("Items")

local Players = game:GetService("Players")

-- // Owner Functions \\ --

-- Claiming tycoon

Items.ClaimTycoonSign.Top.ClickDetector.MouseClick:Connect(function(player)
	if Values.Owner.Value == 0 then
		if player:FindFirstChild("OwnATycoon").Value == false then
			Values.Owner.Value = player.UserId
			player:FindFirstChild("TycoonOfPlayer").Value = Tycoon.Name
			player:FindFirstChild("OwnATycoon").Value = true
			
			while wait() do
				Items.ClaimTycoonSign.Top.SurfaceGui.TextLabel.Text = tostring(player.Name.."'s ".."Tycoon")
			end
		end
	end
end)


-- // buying system \\ --

-- cloning system

for i,OriginalItems in pairs(script.Parent.Parent:WaitForChild("BoughtItems"):GetChildren()) do
	local ItemClones = OriginalItems:Clone()
	ItemClones.Parent = game.ReplicatedStorage
	OriginalItems:Destroy()
end

-- buying systeem

Players.PlayerAdded:Connect(function(player)
	
	local Debounce = false
	
	for i,Button in pairs(Buttons:GetChildren()) do
		Button.ButtonPart.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") then
				if Values.Owner.Value == player.UserId then
					local NewItem = game.ReplicatedStorage:FindFirstChild(Button.Item.Value):Clone()
					
					Button.Parent = nil
					NewItem.Parent = game.Workspace.Tycoons:FindFirstChild(player.TycoonOfPlayer.Value).BoughtItems
				end
			end
		end)
	end
end)

-- // money functions \\ --

local Debounce = false

Players.PlayerAdded:Connect(function(player)
	script.Parent.Parent.Items.CashRecolector.Top.SurfaceGui.TextButton.MouseButton1Down:Connect(function()
		if Values.Owner.Value == player.UserId then
			if Debounce == false then
				Debounce = true

				player:WaitForChild("leaderstats").Money.Value += Values.CashValue.Value
				wait()
				Values.CashValue.Value = 0
				wait(1)
				Debounce = false
			end
		end
	end)
end)

while wait() do
	script.Parent.Parent.Items.CashRecolector.Top.SurfaceGui.TextLabel.Text = Values.CashValue.Value
end

Here is a video so you guys can see:

In more detail, what happens is that when the player two buys the dropper, the dropper appears in the player’s 1 tycoon. and i don’t know why that happens.

if you guys need an explanation, tell me.

Thank you :slight_smile:

2 Likes

Is your script a local script?

It is a script inside a folder for the Tycoon scripts

Oh, my bad I should of fully watched the video before I responded. bad habbit of mine. Sorry to confuse you if I did

You aren’t specifying a position for the things you buy. This works fine for Player 1 since cloned objects keep the position of the object they were cloned from, and I imagine you made tycoon 1 first and then duplicated it for tycoon 2. You can fix this by setting NewItem.Position yourself, or by having a different folder of droppers setup beforehand, with the position already set.

Also just a thing to note, you should keep the droppers in ServerStorage and not ReplicatedStorage. In ReplicatedStorage, exploiters will be able to clone and use them without buying them.

Im not really seeing any clues to why its not working. Maybe you could add print checks between important pieces of code to see where it doesn’t print.

Ok i’m gonna do that rn. but i have a question, can i put the position of the droppers in a value inside the own droppers?

Edit: Also can you explain in more detail the second method which u said? i mean that thing about making a folder. Thank you

You can, but you would have to have a different value for each tycoon (ie. Tycoon1Position, Tycoon2Position, etc)

For the folders method, you keep the objects for each tycoon in a seperate folder. You have the Tycoon1 folder for the first tycoon, Tycoon2 folder for the second tycoon, and so on. You’ll want to move the items in the folder to wherever they need to be beforehand, so that when you clone them they’ll be in the right position.

To set this up, you can use the fact that variables can be used to search for items. For example:

local tycoon = player:FindFirstChild("TycoonOfPlayer").Value -- Lets assume this is Tycoon1
local tycoonFolder = game.ReplicatedStorage[tycoon] -- This functions the same as game.ReplicatedStorage.Tycoon1

Then, you can clone the objects out of tycoonFolder instead of having one universal set, which will work as long as you set up each folder correctly. This might be a bit complicated, but hope it helps!

ok i’m gonna try that

Thank you

1 Like

To understand you. What are you saying is that i need to make a folder in the tycoon named: “Droppers” for example, and then i need to move the droppers in the place that i want them to be, and the next thing to do is move in the explorer the droppers in that folder, right? and i need to change the cloned items parent to ServerStorage and not replicated storage. Tell me if i’m right

Edit: a thing that i don’t understand is that i don’t know what u mean with the second variable you made, i mean, it would be game.ReplicatedStorage.Dropper ??

Edit2: Ok this is the explorer:
image
the tycoon2 has the same things. i made the changes but it didn’t work

ok rn i’m trying something different i will tell you if i get it

Ok i tried so hard, i tried like 9 different ways and i can’t get it, please help

Nvm guys, i fixed it but thank you