When a player with a multiplier gamepass joins everyone gets that multiplier

Hello! In my game I have a problem that someone has a multiplier gamepass everyone in the server gets that multiplier. I tried to get the player that owns the tycoon to check if that player has a gamepads but it still does not work. Please Help!

Here is the script.

local ThreeCash = 10988040 --Times Three Cash
local TwoCash = 10970337 --Time Two Cash
local Players = game:GetService("Players")--Service To Players
local player = game.Players.LocalPlayer--Getting Local Player
local MarketplaceService = game:GetService("MarketplaceService")--Getting MarketplaceService
local Owner = script.Parent.Owner.Value

game.Players.PlayerAdded:Connect(function(player)--Getting Player by function
	
	local success, message = pcall(function()
		CashThree = MarketplaceService:UserOwnsGamePassAsync(player.UserId, ThreeCash)
		CashTwo = MarketplaceService:UserOwnsGamePassAsync(player.UserId, TwoCash)
	end)
end)

if script.Parent.Owner.Value == player then
--Part that get processed
for i,v in pairs(script.Parent.Essentials:GetChildren()) do
		if v.Name == "PartCollector" then
		v.Touched:connect(function(Part)
			if Part:FindFirstChild('Cash') then
				if CashThree == true and CashTwo == true then
					Money.Value = Money.Value + Part.Cash.Value * 5
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X5")
					Debris:AddItem(Part,0.1)
				elseif CashThree == true then
					Money.Value = Money.Value + Part.Cash.Value * 3
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X3")
					Debris:AddItem(Part,0.1)
				elseif CashTwo == true then
					Money.Value = Money.Value + Part.Cash.Value * 2
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X2")
					Debris:AddItem(Part,0.1)
				else 
					Money.Value = Money.Value + Part.Cash.Value
					Debris:AddItem(Part,0.1)
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X0")
				end
				--end
			end
		end)
		end
	end
end
3 Likes

You need to put your multiplier check inside your player added, otherwise everyone will get it.

2 Likes

Thanks I didn’t realize I had to do that!

1 Like

Sorry about the late notice, but when I put the multiplier check inside of the player added the Multipliers seem to not work.

So what’s not working? Like the whole script is not working or the multiplier is for the whole server?

1 Like

The gamepass multiplier is going out to the whole server.

Is anything wrong in the script? Is it a local script or just a script? Try making it to the client (local)

Don’t make it in a local script, this won’t actually give the player the multiplier at all.

I have it has a script not a local.

Oh ok, (I just do not really know about local scripts sorry :worried:)

My solution is to create a data store and if player has gamepass the value becomes 2. Will this work?

Probably. (I am assuming that if the value = 2 then they get that boost)

If the player has a x2 boost then the value will be 1. x3 would be 2.

Yes, I’m back. I tweeked the script and made it so the player had a value but it still doesn’t work.

local Players = game:GetService("Players")--Service To Players
local MarketplaceService = game:GetService("MarketplaceService")--Getting MarketplaceService
local ObjValue = script.Parent.Owner.Value
local MyPlayer = Players.LocalPlayer

game.Players.PlayerAdded:Connect(function(player)--Getting Player by function
	local X3Cash = MarketplaceService:UserOwnsGamePassAsync(player.UserId, 10988040)
	local X2Cash = MarketplaceService:UserOwnsGamePassAsync(player.UserId, 10970337)
	Multiplier = player.CashMulti.Value
	
	local success, errormessage = pcall(function()
	if X3Cash and X2Cash then
		Multiplier = 3
	elseif X3Cash then
		Multiplier = 2
	elseif X2Cash then
		Multiplier = 1
	else
		print("Player Does Not Have A Multi Gamepass")
		end
	end)
	if success then
		print("GP")
	else
		print("No GP")
	end
end)

--Part that get processed
for i,v in pairs(script.Parent.Essentials:GetChildren()) do
		if v.Name == "PartCollector" then
		v.Touched:connect(function(Part)
			if Part:FindFirstChild('Cash') then
				if Multiplier == 3 and MyPlayer == ObjValue then
					Money.Value = Money.Value + Part.Cash.Value * 5
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X5")
					Debris:AddItem(Part,0.1)
					print("Player Owns X5")
				elseif Multiplier == 2 and MyPlayer == ObjValue then
					Money.Value = Money.Value + Part.Cash.Value * 3
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X3")
					Debris:AddItem(Part,0.1)
					print("Player Owns X2")
				elseif Multiplier == 1 and MyPlayer == ObjValue then
					Money.Value = Money.Value + Part.Cash.Value * 2
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X2")
					Debris:AddItem(Part,0.1)
					print("Player Owns X2")
				else
					print("Player Does Not Own A Multi Gamepass") 
					Money.Value = Money.Value + Part.Cash.Value
					Debris:AddItem(Part,0.1)
					script.Parent.Essentials.MultiplierDisplay.Display.GUI.Amount.Text = ("X0")
				end
			end
		end)
	end
end

I see that you are doing this on the client. Everything that includes game passes should be done on the server.

The script is Server side though.

Did you get this from a yt tutorial? If not, rewrite the script. I know it sounds dumb but I do that with broken scripts and they work after. It is just little errors you do not realise.

I did not get it from a Youtube tutorial.

LocalPlayer can only be accessed on the client. Use the playeradded event to get a new player.