Gamepass and group join check not working as intended?

So I’ve been trying to figure out what is wrong. By default a player gets 22 cash each kill. If they join the group they get 11 extra cash each kill. And when they own VIP they get 22 extra (total 55 cash) each kill. Though, one player has been receiving 55 cash from killing even though he doesn’t own the gamepass or is in the group. I myself don’t even earn the extra cash despite owning the gamepass and being in the group.


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)
				
				Killer.leaderstats.XP.Value = Killer.leaderstats.XP.Value + 22

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)

				Killer.leaderstats.Cash.Value = Killer.leaderstats.Cash.Value + 22

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)

				Killer.leaderstats.Kills.Value = Killer.leaderstats.Kills.Value + 1

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)


local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 48713039 -- the funny id

game.Players.PlayerAdded:Connect(function(player)
	 owned = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
end)


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") and owned == true then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)

				Killer.leaderstats.Cash.Value = Killer.leaderstats.Cash.Value + 22

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		while true do
		local v3 = wait(1)
		if not v3 then
			break
		end
		v3 = player.leaderstats.Max
		v3.Value = player.leaderstats.Level.Value * 100
	end
end)
	end)
	

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		player.leaderstats.Streak.Value = 0
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)

				Killer.leaderstats.Streak.Value = Killer.leaderstats.Streak.Value + 1

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			if Humanoid:FindFirstChild("creator") and player:IsInGroup(10074015) then
				print(player, "was killed by", Humanoid.creator.Value)
				local Killer = Humanoid.creator.Value
				local KillerPlayer = game.Players:FindFirstChild(Killer)

				Killer.leaderstats.Cash.Value = Killer.leaderstats.Cash.Value + 11

			else
				print(player, "was not killed by another player")
			end
		end)
	end)
end)

I can’t figure out what is wrong, please help out if you can.

Why do you have so many PlayerAdded events when you can just combine them all into one?

If you combine everything into one big script event, it can make the script so much cleaner.

Your script looks fine, though.

Nvm. I apologize for wasting anyone’s time. Turns out the issue was to change the player part into “Killer” in “MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)” . Also same for the group check. This is solved.