Problem with 2x Coins Script and Coins Count on GUI

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    …
  2. What is the issue? Include screenshots / videos if possible!
    The problem with the 2x Coins(Souls) script is in game(Roblox not roblox studio) everytime you leave and rejoin your coins get doubled. The problem with the Coins(Souls) count is when you reset your character the value gets set to 0.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to change something on the script but i couldn’t fix it and i’ve looked on the forum but couldn’t find a solution.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

--2x Coins 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)
--Coins Count Script GUI
local souls = script.Parent.Parent.Parent.Parent.leaderstats.Souls
souls.Changed:Connect(function()
	script.Parent.Text = ""..souls.Value
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Also the 2x Coins(Souls) has 2 children inside it. StringValue"Currency" and IntValue “GamepassId”

This line is unneeded, you can do :WaitForChild.

local leader = player:WaitForChild("leaderstats")

I think the problem happens with the loading of the Coins. Maybe try adding a Bool Value which checks if the currency was added. When it was added, the script will detect new currency.

I got a new script for 2x Coins all works now, but do you have any idea how can i fix the 2nd Issue?

Go to the ScreenGui and turn ResetOnSpawn to false. If it still doesn’t work, try this:

local Value = script.Parent.Parent.Parent.Parent.leaderstats["Value name"]
script.Parent.Text = "$".. Value.Value -- Setting the text right away
Value.Changed:Connect(function()
	
	script.Parent.Text = "$".. Value.Value
	
end)

Okey thanks it works!
30 characters

ik this post was a while ago, but i was dealing with the same issue! i couldnt find anything until now, tysm!