Due to issues involving the script that I’ve made, I’m trying another approach. I wish to know when all of the parts have gained a transparency value of 0.25 and once this happens, end the script only for it to repeat upon the activation of a tool. Below you’ll find the code that I already have.
Serverscript
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OreTouchedEvent = ReplicatedStorage.OreTouchedEvent
local OreTransparency = 0
local debounce = false
OreTouchedEvent.OnServerEvent:Connect(function(player, Ore)
local char = player.Character
local hum = char:FindFirstChildOfClass("Humanoid")
if not debounce then
if hum then
local pickaxe = char:FindFirstChild("Pickaxe")
if pickaxe then
for _, v in(Ore:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "Hitbox" then
v.Transparency += 0.25
end
end
end
end
end
end)
Because I’m creating a mining system, and with this, capability to mine ore with a pickaxe. Transparency is used as a progress indicator as to how close the ore is from being mined and currency granted.
OreTouchedEvent.OnServerEvent:Connect(function(player, Ore)
local char = player.Character
local hum = char:FindFirstChildOfClass("Humanoid")
if not debounce then
if hum then
local pickaxe = char:FindFirstChild("Pickaxe")
if pickaxe then
for _, v in(Ore:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "Hitbox" then
v.Transparency += 0.25
end
end
end
debounce = true
task.wait(Your tool's cooldown time)
debounce = false
end
end
end)
You’re already increasing the transparency of all the baseparts whose name is not “Hitbox” by another 0.25, all at once with the loop