I don't know why CashPiles is underlined in red
local moneyData = script.Parent:GetChildren()
if CashPiles.Name == "Stack" then cashpiles:FindFirstChild('Cash').Touched:connect(function(hit) if hit.Parent then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then if cashpiles:FindFirstChild('Cash').Transparency == 0 then plr.Wallet.Value = 5000 local parts = cashpiles:GetChildren() for p = 1, #parts do if parts[p]:IsA('Part') then if parts[p]:FindFirstChild('Texture') then parts[p]:FindFirstChild('Texture').Transparency = 1 end parts[p].Transparency = 1 parts[p].CanCollide = false end end end end end end) end
In Lua, or most coding programs, you absolutely need to understand that capital letters mean everything.
A perfect example of this would be a part of your script that states:
"Touched:connect(function(hit)"
This is wrong. The correct line of code would be:
"Touched:Connect(function(hit)"
Although it works the same way, you may be thinking, whats the difference? Well, ROBLOX has deprecated "connect" as it does not coincide with the capital letters on other things within the Lua program.
You must make sure every line of your code, especially when outlining something such as CashPiles, that you do it exactly.
tl;dr, it's not working because you defined "CashPiles" but then used "cashpiles" later on in the code. They both need to be "CashPiles".
you didn't make cashpiles:FindFirstChild("Cash") a capital c and P
if CashPiles.Name == "Stack" then cashpiles:FindFirstChild('Cash').Touched:connect(function(hit) if hit.Parent then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) local hum = hit.Parent:FindFirstChild("Humanoid") if hum then if CashPiles:FindFirstChild('Cash').Transparency == 0 then plr.Wallet.Value = 5000 local parts = CashPiles:GetChildren() for p = 1, #parts do if parts[p]:IsA('Part') then if parts[p]:FindFirstChild('Texture') then parts[p]:FindFirstChild('Texture').Transparency = 1 end parts[p].Transparency = 1 parts[p].CanCollide = false end end end end end end) end