Preview:
local Players = game:GetService("Players")
local collectPart = script.Parent
local collectable = true
local collectValue = 1
local respawnTime = 10

collectPart.Touched:Connect(function(otherPart)
	local character = otherPart:FindFirstAncestorWhichIsA("Model")
	if not character then return end

	local player = Players:GetPlayerFromCharacter(character)
	if not player then return end
	
	local leaderstats = player:FindFirstChild("leaderstats")
	if not leaderstats then return end

	local collectItem = leaderstats:FindFirstChild("Gems")
	if not collectItem then return end
	
	if collectable then
		collectable = false
		
		collectItem.Value += collectValue

		collectPart.Transparency = 1
		wait(respawnTime)
		collectPart.Transparency = 0

		collectable = true
	end
end)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter