Hey! I'm here again -- with another question:
So , I started debugging using the Lua debugger at if wander==false and hit. blalblalba
it works fine, but when the function is activated multiple times (which doesnt do anything besides activating since canenable is false), the code abruptly stops.
Alright, that's the first "error".
(Not the main question,however it comes first in the script so I thought I'll show it first)
local wander = test.wanderstate.Value
wander = false -- MOB STATE
canenable = true
local enabler = script.Parent.Parent.Cave.enabler
enabler.Touched:Connect(function(hit)
if wander == false and hit.Parent:FindFirstChild("Humanoid") and canenable == true
then wander = true
canenable = false
wait()
print(wander)
wait(3)
canenable = true
return wander
end
end)
Second "error" - the main question: Why do BoolValue's value not update with script? when I set the BoolValue of wander to true manually, this code runs fine :
if wander == true then
print("initiate")
loadedInactive:Stop()
loadedActivate:Play()
wait(6)
while wander == true do
loadedWalk:Play()
moveto = Vector3.new((math.random(-30,30)+test.Torso.Position.X),0,(math.random(-30,30)+test.Torso.Position.Z))
test.Humanoid:MoveTo(moveto) -- MOVE TO RANDOM COORDINATES ABOVE
test.Humanoid.MoveToFinished:Wait(5)
for i=1,3 do
if math.random(1,3) == 3 then
loadedSwing:Play()
end
if wander == false then break
else
loadedWalk:Stop()
loadedIdle:Play()
wait(5) -- COOLDOWN
loadedIdle:Stop()
end
end
but when BoolValue is set to true using the first .Touched function, the script does not activate,even though when I put in print(wander) in the function and it says true.

1 comment
Thanks! Your TrueOrFalse.Changed did the trick :)