Why is this boolvalue not changing?

Ello DevForum lads,

so i have this lock feature on my door and i just realized the whole time the the boolvalue wasnt changed and instead some variable inside the script was getting set true and false. However why dosent it change the boolvalue ??? am i doing something wrong ???

local Model = script.Parent
local Handler = Model:WaitForChild("Handler")
local Knob = Model:WaitForChild("Knob")
local Locked = Model:WaitForChild("Locked")
local Unlocked = Model:WaitForChild("Unlocked")
local Door = Model:WaitForChild("Door")

local DoorLock = Model.Werte:WaitForChild("DoorLock")
local Rammed = Model.Werte:WaitForChild("Rammed")

local OpenOrClose = Model.Werte:WaitForChild("OpenOrClose")
local LockDoor = Model.Werte:WaitForChild("LockDoor")
local KnockDoor  = Model.Werte:WaitForChild("KnockDoor")


local IsOwner = Model.Parent.WWerte:WaitForChild("VOwner")

-- this just a checker to run functions but this checks if the door wasnt battering rammed or isnt locked
OpenOrClose.OnServerEvent:connect(function(player)
	if DoorLock == true and not OpenOrCloseDebounce and not Rammed then
		OpenOrCloseDebounce = true
		script.Parent.Door.DOpenLocked:Play(true)
		wait(1)
		OpenOrCloseDebounce = false
	elseif not Open and not OpenOrCloseDebounce and not Rammed then
		OpenOrCloseDebounce = true
		OpenDoor()
	elseif Open and not OpenOrCloseDebounce and not Rammed then
		OpenOrCloseDebounce = true
		CloseDoor()
	end
end)
-- Problem starts here
local LockDoorDebounce = false

LockDoor.OnServerEvent:connect(function(player)
if LockDoorDebounce then return end
	LockDoorDebounce = true
	
	if DoorLock == false and player.Name == IsOwner.Value then
		DoorLock = true
		script.Parent.Door.SLock:Play(true)
		script.Parent.Unlocked.Transparency = 1
		script.Parent.Unlocked.CanCollide = true
		script.Parent.Locked.Transparency = 0
		script.Parent.Locked.CanCollide = false
		wait(1)
	elseif DoorLock == true and player.Name == IsOwner.Value then
		DoorLock = false
		script.Parent.Door.SUnlock:Play(true)
		script.Parent.Unlocked.Transparency = 0
		script.Parent.Unlocked.CanCollide = false
		script.Parent.Locked.Transparency = 1
		script.Parent.Locked.CanCollide = true
		wait(1)
	end
	LockDoorDebounce = false
end)
-- Problem ends here

I assume DoorLock is the BoolValue. You need to do DoorLock.Value = boolean, instead of DoorLock = boolean, you would only be changing the variable, not the value.

1 Like

From what I can tell, the "DoorLock " is an instance, which I’m assuming is the boolean value? Which means you should use “DoorLock.Value == Something” for if statements, and for setting the value you should do DoorLock.Value = true or false.

omg i just realized this im so stupid. I literlly added in the battering ram that the boolvalue gets set to true wich worked and then i open my door script and i wonder why the hell it dosent chance xD

1 Like

yea same as the answer above i literly forgot to add .Value

2 Likes

It’s a mistake we all made when we began. You learn by mistakes!

4 Likes