0 views0 copies0 likes

Quest Progress Counter for Crystal Hunts

Universal script

Copy it, then test it in your own Studio place.

Utilities Verified

Script code

18 lines ยท 0.8 KB
Download
local Players = game:GetService("Players")local collected = {}for _, crystal in workspace:WaitForChild("QuestCrystals"):GetChildren() do	if not crystal:IsA("BasePart") then continue end	crystal.Touched:Connect(function(hit)		local character = hit:FindFirstAncestorOfClass("Model")		local player = character and Players:GetPlayerFromCharacter(character)		if not player then return end		local seen = collected[player] or {}		collected[player] = seen		if seen[crystal] then return end		seen[crystal] = true		local total = (player:GetAttribute("QuestCrystals") or 0) + 1		player:SetAttribute("QuestCrystals", total)-- โ€ฆopen Get script for the full source

About this script

Add anchored parts inside Workspace.QuestCrystals. Collecting one for the first time increments the player's QuestCrystals attribute. The tracked crystals are personal even though the parts remain visible to everyone. At three crystals, CrystalQuestComplete becomes true for your reward handler to read. Try having two players collect the same crystal and verify that each keeps their own progress.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local Players = game:GetService("Players")
local collected = {}
for _, crystal in workspace:WaitForChild("QuestCrystals"):GetChildren() do
	if not crystal:IsA("BasePart") then continue end
	crystal.Touched:Connect(function(hit)
		local character = hit:FindFirstAncestorOfClass("Model")
		local player = character and Players:GetPlayerFromCharacter(character)
		if not player then return end
		local seen = collected[player] or {}
		collected[player] = seen
		if seen[crystal] then return end
		seen[crystal] = true
		local total = (player:GetAttribute("QuestCrystals") or 0) + 1
		player:SetAttribute("QuestCrystals", total)
		player:SetAttribute("CrystalQuestComplete", total >= 3)
	end)
end
Players.PlayerRemoving:Connect(function(player) collected[player] = nil end)