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 one in mainItems work but the other one doesnt
Try placing print(“whatever”) into places where important things happen (like when parts touch the collector) and see what happens. Also for future reference use the preformatted text option to make the code more readable.
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 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.newmainItems.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)
What you have to do is to see where it goes wrong, so you should place print or warns to wherever you suspect.
For example the part where it checks if its a player or not, or checking if the owner is player etc.
Also the brickcolors strings seem to be gray for me, for some reason. Maybe it doesn’t change the color?