I am making a sandbox tycoon and i have a money collector that adds money directly to the players cash, but it only works on the first one that touches it. Please help!
function onTouched(hit) if hit.Name == "Cash" then game:GetService("ReplicatedStorage").Owner1.OnServerEvent:connect(function(player) player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + hit.Value.Value --Gives money based on value in money hit:remove() end) end end script.Parent.Touched:Connect(onTouched)
Also, for some reason it adds a touch interest in the part that has the script in it.
Im not sure what your asking for but this script gives you cash!
local ting = 0 function onTouched(hit) if ting == 0 then ting = 1 check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") if stats ~= nil then local cash = stats:findFirstChild("Cash") cash.Value = cash.Value +10000000 wait(2) end end ting = 0 end end script.Parent.Touched:connect(onTouched)