So I am making an obby, I have a coin after every 2-3 stages. Once I collect that specific coin, it adds to my leader board. If I try to collect the coin again, I can't collect it again.

But if I rejoin the game, I can still collect the coins which I collected before. I don't want that to happen. No matter if the player again joins the game or what. It should not be able to collect it twice.

I have this script inside the coin which does not allow the player to collect it twice, but if the player rejoin the game, he can collect it twice.

Script inside the coin:

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
			script.Sound:Play()
			wait(1)
			script.Parent.Transparency = 1
			wait(1)
			script.Parent.Transparency = 0
			
		end
	end	
end)

Please help me.

Thanks

1 comment

0

you probably need to save the player's data and when this specific player joins the player receives the data that was saved but i have no idea how that works nor have i checked but i guess you can check on your own