This script works without the debounce but needs one to stop it increasing by more than 15. With the debounce it breaks after "everything is awesome" and the value isn't increased. Been really struggling with this one today! MD
Detector = script.Parent
local values = {"NA","One","OneBD","Two","TwoBD","Eleven","ElevenBD","TwentyTwo"} --Creates a list of values (make sure you put in the correct names)
enabled = true
BrickValue = 15
function onTouch(part)
if not enabled then
return
end
enabled = false
print("everything is awesome")
local player = game.Players:GetPlayerFromCharacter(part.Parent)
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
print("Humanoid doesn't = nil! yay!")
local bus = Workspace:FindFirstChild(player.Name.."'s Car")
if bus:FindFirstChild("CurrentScore")then
bus.CurrentScore.Value = bus.CurrentScore.Value + BrickValue
wait(5)
enabled = true
else
for i,v in pairs(values) do
if bus:findFirstChild(v) then
v.Value = 0
print("This bit executed")
enabled = true
end
end
end
end
end
Detector.Touched:connect(onTouch)
