Code works just want someone's opinion on it or how to improve it. Feel free to say anything.
local BricksLocation = game.Workspace:FindFirstChild('Fixbricks')
local BricksDebounce = {} -- ServerSide Debounce
if BricksLocation then
for _, brick in pairs(workspace.Fixbricks:GetChildren()) do
if brick.Name == "fixbrick" and brick:FindFirstChild("ProximityAttachment") then
local ProximityAttachment = brick:FindFirstChild('ProximityAttachment')
ProximityAttachment.ProximityPrompt.Triggered:Connect(function(plr)
local Teams = game:GetService("Teams")
if plr.Team == Teams.Worker and not BricksDebounce[plr.Name] then
BricksDebounce[plr.Name] = true
local reward = GetReward(2)
ServerDataFolder[plr.Name].leaderstats.Cash.Value = ServerDataFolder[plr.Name].leaderstats.Cash.Value +reward
brick.ParticleEmitter.Enabled = false
brick.Sparks:Stop()
ProximityAttachment.ProximityPrompt.Enabled = false
wait(20)
BricksDebounce[plr.Name] = nil
wait(200)
brick.ParticleEmitter.Enabled = true
ProximityAttachment.ProximityPrompt.Enabled = true
brick.Sparks:Play()
end
end)
end
end
end

2 comments
Gotcha on there first stuff, but I thought the .Triggered is listening so it would work fine without coroutines?
you're right, I read this on my phone and I looked real hard but didn't see the connect, lol. sorry.