So. I’m working on a COD Zombies game, and I’m trying to create the barrier system. (Basically, while the zombie is touching the hitbox, a board gets deleted every second)
Script
local part = script.Parent
local b1 = part.board1
local b2 = part.board2 -- Assigning varibles and stuff
local b3 = part.board3
local b4 = part.board4
while task.wait(1) do
local touching = part:GetTouchingParts() -- find parts touching the hitbox
if touching.Name == "Zombie" then
if part.part.Value.Value == 0 then -- checks if no boards are existing
print("no boards to break")
checkforboardvalue()
return
end
elseif touching.Name ~= "Zombie" then
part.Value.Value = part.Value.Value - 1 -- lower the valye and update boards visually
checkforboardvalue() -- cause of error ---
print("Value is now:".. part.Value.Value) -- not printing for some reason??
end
end
function checkforboardvalue()
if part.Value.Value == 0 then
b1.Transparency = 1
b2.Transparency = 1
b3.Transparency = 1 -- update boards visibly
b4.Transparency = 1
part.CanCollide = false -- let zombie walk through
elseif part.Value.Value == 1 then
b1.Transparency = 0
b2.Transparency = 1
b3.Transparency = 1
b4.Transparency = 1
part.CanCollide = true
elseif part.Value.Value == 2 then
b1.Transparency = 0
b2.Transparency = 0
b3.Transparency = 1
b4.Transparency = 1
part.CanCollide = true
elseif part.Value.Value == 3 then
b1.Transparency = 0
b2.Transparency = 0
b3.Transparency = 0
b4.Transparency = 1
part.CanCollide = true
elseif part.Value.Value == 4 then
b1.Transparency = 0
b2.Transparency = 0
b3.Transparency = 0
b4.Transparency = 0
part.CanCollide = true
end
end
The issue is that, in the log, It keeps saying that it’s calling a nil value however, the value is not nil, and is actually 4 (for the 4 barriers) anyone know what the issue is? (The line causing the error is in the script.)