How would I make it so only one player makes money

Hello Devforum, about 10 minutes ago, me and my friends were about to play my tycoon and theres a problem where, 1 player makes cash, all of them do, it makes sense on why, but I dont know how to fix it

Script:

local players = game:GetService("Players")

local collecter = script.Parent

local basepart = collecter.BasePart

basepart.Touched:Connect(function(hit)
	if hit.Name == "Drop" then
		for _, player in ipairs(players:GetPlayers()) do
			player.leaderstats.Cash.Value += hit.CashValue.Value
		end
		hit:Destroy()
	end
end)
2 Likes

you are getting all the players, so the variable player, becomes everyone. Is there any way for the block to know whos tycoon it is?

Yea, I got players UserIds printed in to the tycoons attributes(no idea how i would use that)

So yea, Use that and instead do something like this, replacing the USERID

if hit.Name == "Drop" then
game.Players:GetPlayerByUserId(USERID).leaderstats.Cash.Value += hit.CashValue.Value
hit:Destroy() 
end

Instead of looking for everyone, it gets one player

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.