Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

A Wait until function?(answered)

Answered

1 comment

0

Because we do not particularly take request questions. Have you looked into creating this script yourself or have you expected the community to generate the solution for you?

1 answer

✓ Accepted answer

If you put the coins in a model/folder and call them 1, 2, 3 etc., you can do something like this in a script inside that model/folder (assuming you have a leaderstat called Coins):

for _,v in pairs(script.Parent:GetChildren()) do
	if v:IsA("BasePart") then
		v.Touched:Connect(function(hit)
			if not script.Parent:FindFirstChild(tonumber(v.Name)-1) then
				local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
				if plr and plr:FindFirstChild("leaderstats") then
					plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
				end
				v:Destroy()
			end
		end)
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.