I had to rewrite your code because it was posted as an image to see if I could replicate the issue you’re having. I could not replicate that issue.
Script in StarterCharacterScripts:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local function onStateChanged(oldState, newState)
local EDU = true
-- Simulate for loop
for _, v in ipairs(Character:GetChildren()) do
if v:IsA("BasePart") then
EDU = false
break
end
end
print(EDU)
if true then
print("true is truthy")
end
end
Humanoid.StateChanged:Connect(onStateChanged)
Output:
Needs more context and/or debugging on your part.
1: For those who are security conscious: this website is open source. It just does not possess a certificate so it’s marked as not secure. CNAME for the website in the GitHub repository which allows the repository to be hosted on that site.