Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why is print statement not firing when humanoid.sit is true?

Asked by 3 years ago
Edited 3 years ago

this is the code its a script running on the server

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
    print("ok")
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character.Humanoid
        print("ok")
        if Humanoid.Sit == true then
            print("ok")
        else
            print("NO!")
        end
    end)
end)

everything is working fine expect the third print which just doesnt print at all even if humanoid.sit is ture

1 answer

Log in to vote
0
Answered by 3 years ago
local Players,main=game:GetService"Players",function(player,char,hum)

    print(hum.Sit and "ok" or "NO!")

end


local function onCharacterAdded(char)
    local hum,player=char.Changed:Wait()and char.Humanoid,Players:GetPlayerFromCharacter(char)
    hum:GetPropertyChangedSignal"Sit":Connect(function()
        main(player,char,hum)
    end)
    main(player,char,hum)
end
local function onPlayerAdded(player)
    print("ok")
    player.CharacterAdded:Connect(onCharacterAdded)
    local char=player.Character
    if char then onCharacterAdded(char)end
end;Players.PlayerAdded:Connect(onPlayerAdded)
for _,v in ipairs(Players:GetPlayers())do
    onPlayerAdded(v)
end

Ad

Answer this question