I was running my code, and I got an error called "attempt to index nil with character. Can someone explain what this means?
local Door1 = script.Parent.Door1 local Door2 = script.Parent.Door2 local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:wait() local neon = script.Parent.Button.Neon local neonb = script.Parent.Button2.Neon2 local debounce = false local opened = false -- new variable local TS = game:GetService("TweenService") local TI = TweenInfo.new(0.8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) local DoorOpen1 = {CFrame = Door1.CFrame + Door1.CFrame.lookVector * -4} local DoorOpen2 = {CFrame = Door2.CFrame + Door2.CFrame.lookVector * 4} local DoorClose1 = {CFrame = Door1.CFrame } local DoorClose2 = {CFrame = Door2.CFrame } local open1 = TS:Create(Door1, TI, DoorOpen1) local close1 = TS:Create(Door1, TI, DoorClose1) local open2 = TS:Create(Door2, TI, DoorOpen2) local close2 = TS:Create(Door2, TI, DoorClose2) local sound = script.Parent["BMRF Sliding Door Open"] local closesound = script.Parent["BMRF Sliding Door Close"] script.Parent.Parent.ToggleDoor.OnServerEvent:Connect(function() if player.Backpack:FindFirstChild("card") or player.Character:FindFirstChild("card") then if opened == false then -- is it OPEN...? if debounce == false then -- then check debounce debounce = true opened = true neon.BrickColor = BrickColor.new("Bright green") neonb.BrickColor = BrickColor.new("Bright green") sound:Play() open1:Play() open2:Play() wait(1) -- wait a bit (optional) debounce = false -- reset the debounce end elseif opened == true then if debounce == false then -- same thing as above debounce = true opened = false neon.BrickColor = BrickColor.new("Really red") neonb.BrickColor = BrickColor.new("Really red") closesound:Play() close1:Play() close2:Play() wait(1) debounce = false end end end end)