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

It gives me "attempt to compare number with boolean" error on the if s > 1 part..?

Asked by 5 years ago
wait()
local WA = Instance.new("Animation")
local IA = Instance.new("Animation")
local JA = Instance.new("Animation")
IA.AnimationId = "rbxassetid://2864159998"
JA.AnimationId = "rbxassetid://2864429112"
WA.AnimationId= "rbxassetid://2864578077"

local humanoid = script.Parent.Humanoid


local IdleAnimation = humanoid:LoadAnimation(IA)
local JumpAnimation = humanoid:LoadAnimation(JA)
local WalkAnimation = humanoid:LoadAnimation(WA)

humanoid.Running:Connect(function(s)
    if s > 1 then
        IdleAnimation:Stop()
        WalkAnimation:Play()
    else

        IdleAnimation:Play()
        WalkAnimation:Stop()

    end

end)

humanoid.Jumping:Connect(function(s)
    if s > 1 then
        print("lol")
    end
end)
0
line 30 octopusprime101 4 — 5y
0
The argument passed to your Jumpingcallback function is the boolean that determines if they're jumping. Not a number. User#24403 69 — 5y
0
so what do i do?? octopusprime101 4 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago
Edited 5 years ago

Well, the paramater on the Running and Jumping event is a boolean value, so it will either be false or true, and you obviously can't compare a boolean and a number. So I guess what you want to do is check if it's true. So that's waht you gotta do, and always keep on mind that paramaters are almost never numbers, they are all the time just a bool or an object as incapaz said.

Now this is waht you wanna do:

humanoid.Running:Connect(function(s)
    if s == true then
        IdleAnimation:Stop()
        WalkAnimation:Play()
    else

        IdleAnimation:Play()
        WalkAnimation:Stop()

    end

end)

humanoid.Jumping:Connect(function(s)
    if s == true then
        print("lol")
    end
end)
0
thanksss octopusprime101 4 — 5y
0
np! starmaq 1290 — 5y
0
that was mcandrobloxunited not me User#24403 69 — 5y
0
oh, he removed his comment so i thought i was wrong xd so i edited the answer and said its you starmaq 1290 — 5y
0
sorry starmaq 1290 — 5y
Ad

Answer this question