Need help with gamepass and event scripts

Hello, i recently posted a topic about this but i didnt explain it fully, and i also didnt get much help with it either. but in my game coin farming simulator i have a 2x coin gamepass, and sometimes when you rejoin the game, your coins will double.

heres the script:

game.Players.PlayerAdded:Connect(function(player)
	
	local marketservice = game:GetService("MarketplaceService")
	
	local can = true
	repeat wait() until player:FindFirstChild("leaderstats")
	local leader = player:FindFirstChild("leaderstats")
	if leader then
	repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
	local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
		if currency then
			local folder = Instance.new("Folder",player)
			folder.Name = "2xGamepass"
			local oldmoney = Instance.new("IntValue",folder)
			oldmoney.Name = "OldMoney"
			oldmoney.Value = currency.Value
			local give2x = Instance.new("IntValue",folder)
			give2x.Name = "Give2x"
			give2x.Value = 0
			
			currency.Changed:Connect(function()
				if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then
				
					
				if can == true then
					can = false
				if currency.Value > oldmoney.Value then
				give2x.Value = currency.Value - oldmoney.Value
			
				currency.Value = currency.Value + give2x.Value
				
				oldmoney.Value = currency.Value
					can = true
					else
						
							oldmoney.Value = currency.Value
							can = true
						
						
				end
					
				end
				else
					oldmoney.Value = currency.Value
				end
			end)
			
		end
	end
end)

i got this script from a tutorial and was told that it has a glitch that doubles your coins when you rejoin. can anyone help me fix that glitch?

my other issue is i want to do a coin event, at first i didn’t know how and i looked everywhere, but found nothing. so i tried using my 2x coin gamepass, and… it worked!

the only issue is, ive tried making it 10x coin event, but it wont go past 4x. and saying i used the gamepass script, it also multiplies your coins when you rejoin. the first time i did the coin event it worked, and now im trying to do it again and nothing works at all… heres the script i used for it

local can = true
repeat wait() until player:FindFirstChild("leaderstats")
local leader = player:FindFirstChild("leaderstats")
if leader then
	repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
	local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
	if currency then
		local folder = Instance.new("Folder",player)
		folder.Name = "CoinEvent"
		local oldmoney = Instance.new("NumberValue",folder)
		oldmoney.Name = "OldMoney"
		oldmoney.Value = currency.Value
		local give4x = Instance.new("NumberValue",folder)
		give4x.Name = "Give4x"
		give4x.Value = 0
		
		
		if can == true then
			can = false
			if currency.Value > oldmoney.Value then
				give4x.Value = currency.Value - oldmoney.Value
				
				currency.Value = currency.Value + give4x.Value
				
				oldmoney.Value = currency.Value
				can = true
			else
				
				oldmoney.Value = currency.Value
				can = true
				
			end
			
		end
	end
end

end)

i know this is a lot, but i really hope someone can help me solve this issue with both the coin event and gamepass… and make them both work correctly as they should! thank you

P.S. I’m aware i used a gamepass script for an event but i didnt know what else to do, as i said i couldnt find anything :grimacing:

welp i dont think anyone is gonna reply and help…

nevermind! i found it out myself, finally!

1 Like