You can write your topic however you want, but you need to answer these questions:
- **What do you want to achieve? I want to have multiple CashCollectors in my Tycoon, which spawn when buying the next Floor
- **What is the issue? Every CashCollector (except1) doesnt work and doesnt react to being touched.
- **What solutions have you tried so far? Looked for the issue(dont get the .Touched), tried different ways of refferring
So I have a Tycoon where all Items you buy get cloned into the Folder Purchases, but the CashCollector there doesnt work(see images)
tycoon.MainItems.CashCollector.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if values.OwnerValue.Value == player then
if player.Character.Humanoid.Health > 0 then
mainItems.CashCollector.Button.BrickColor = BrickColor.new("Really red")
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + values.MoneyValue.Value
values.MoneyValue.Value = 0
playSound(mainItems.CashCollector, audio.CashSound.SoundId)
task.wait(1)
mainItems.CashCollector.Button.BrickColor = BrickColor.new ("Lime green")
end
end
end
end)
tycoon.Purchases.Floor1.CashCollector.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if values.OwnerValue.Value == player then
if player.Character.Humanoid.Health > 0 then
tycoon.Purchases.Floor1.CashCollector.Button.BrickColor = BrickColor.new("Really red")
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + values.MoneyValue.Value
values.MoneyValue.Value = 0
playSound(tycoon.Purchases.Floor1.CashCollector, audio.CashSound.SoundId)
task.wait(1)
tycoon.Purchases.Floor1.CashCollector.Button.BrickColor = BrickColor.new ("Lime green")
end
end
end
end)
The Problem is that the Button doesnt even detect the touch of the player