Alright so basically I have a table debounce where its like this, but problem is that the objects are the same name and its only working for one of them sadly
local Debounces = {}
if not Debounces[something.Name] then
Debounce[something.Name] = true
wait(5)
Debounce[something.Name] = false
end
That is why you set the reference to nil, thus it can get garbage collected since it will be removed from the table, setting a index to nil removes it.
Also, what you should really do is use a weak table to remove the reference when the object gets destroyed:
local Debounces = {}
setmetatable(Debounces, {__mode = "v"})
if not Debounces[something] then
Debounce[something] = true
wait(5)
Debounce[something] = nil
end
Alright I just tried you 3nd solution and it didnt work also I dont know whats up with this, when I change the objects im referring to, to different names it works
Yeah I tried that solution and it didnt work oof, @cjjdawg
This is the code
elseif not hit and not Stopped[car.Name] then
for index,sign in pairs(stopSigns:GetChildren()) do
if (car.Position - sign.PrimaryPart.Position).Magnitude < 11 then
Stopped[car.Name] = true
BodyVelocity.Velocity = Vector3.new(0,0,0) - car.CFrame.lookVector - Vector3.new(0,0,.005)
wait(.2)
BodyVelocity.Velocity = Vector3.new(0,0,0)
print(car.Name.." has been stopped!")
wait(1.2)
BodyVelocity.Velocity = car.CFrame.LookVector * 11.1
print(car.Name.." can now move!")
wait(1.5)
Stopped[car.Name] = nil
else
print(car.Name.." is accelerating . . !")
BodyVelocity.Velocity = car.CFrame.LookVector * 11.1
end
end
Ensure the rest of your code is correct because two objects will all the same properties will be different because they point to different locations in memory.