Hello, I am trying to make a script where if the client receives a signal, it highlights all nearby ores and their rarity colors. This is my script:
game.ReplicatedStorage.Events.HighlightOres.OnClientEvent:Connect(function()
if canSpelunk == true then
script.Parent.Highlights:ClearAllChildren()
canSpelunk = false
script.activate.PlaybackSpeed = math.random(5,15)/10
script.activate:Play()
for i,ore in pairs(workspace.possibleOreSpots:GetDescendants()) do
if ore:FindFirstChild("isOre") then
local rarity = ore.rarityForSpelunkers.Value
if rarity == "common" then
c = Color3.fromRGB(255,255,255)
elseif rarity == "rare" then
c = Color3.fromRGB(0,0,255)
elseif rarity == "epic" then
c = Color3.fromRGB(170, 0, 255)
elseif rarity == "legendary" then
c = Color3.fromRGB(255, 170, 0)
elseif rarity == "mythical" then
c = Color3.fromRGB(255, 0, 70)
c = Color3.fromRGB(255, 0, 70)
elseif rarity == "exotic" then
c = Color3.fromRGB(255, 255, 0)
elseif rarity == "ethereal" then
c = Color3.fromRGB(0, 255, 255)
elseif rarity == "celestial" then
c = Color3.fromRGB(25, 0, 100)
end
local h = script.Highlight:Clone()
h.Adornee = ore
h.FillColor = c
h.OutlineColor = c
h.Enabled = true
h.Parent = script.Parent.Highlights
end
end
end
task.wait(15)
for i,h in pairs(script.Parent.Highlights:GetChildren()) do
if h:IsA("Highlight") then
game.TweenService:Create(h,TweenInfo.new(15,Enum.EasingStyle.Quint,Enum.EasingDirection.In),{FillTransparency = 1, OutlineTransparency = 1}):Play()
end
end
task.wait(15)
canSpelunk = true
end)
But, for some reason, it only highlights certain ores, and these ores remain the only ones that are highlighted every time the signal is activated. How can I fix this?