im making this echolocation script, and for some reason when the sphere touches an object it wont glow as intended
heres the inportant part of the code
soundWave.Touched:Connect(function(hit)
if not table.find(touchTable, hit) then
table.insert(touchTable, hit)
------------
if hit ~= game.Workspace.Baseplate then
local hitColor = hit.Color
local hitTransparency = hit.Transparency
local hitMaterial = hit.Material
local echoTween = Services.TS:Create(hit, TweenInfo.new(1), {Color = Color3.new(0.917647, 0.698039, 0.25098), Transparency = 0.5})
echoTween:Play()
hit.Material = Enum.Material.Neon
print(hitColor,hitMaterial,hitTransparency)
task.wait(5)
print(hitColor,hitMaterial,hitTransparency)
local endTween = Services.TS:Create(hit, TweenInfo.new(1), {Color = hitColor, Transparency = hitTransparency})
endTween:Play()
hit.Material = hitMaterial
end
task.wait(5)
local index = table.find(touchTable,hit)
if index then
table.remove(touchTable, index)
end
end
end)
im not sure whats causing the issue but if i had to assume it’d be the table.
help and feedback is appreciated, thank you for your time