#This function doesnt work, Why?

98 messages · Page 1 of 1 (latest)

formal aurora
#
local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function()
    local State = Humanoid:GetState()
    if State == "Jumping" or "FreeFalling" then
        print("falling")
    else
        print("Landed")
    end
end)

This script is supposed to print "falling" whenever the character jumps or is falling and landed whenever they exit that state, but for some reason the script only prints "falling" why is that?

#

i also tried putting the if statement in a while loop to test if it is the functions fault and it produced the same output

novel fern
#

You should do this instead

local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function()
    local State = Humanoid:GetState()
    if State == "Jumping" then
        print("falling")
    elseif State == "FreeFalling" then
        print("Landed")
    end
end)
formal aurora
novel fern
#

then instead of humanoid.state changed

#

you should just do

#

humanoid.jumping

#

and humanoid.falling

formal aurora
#

two seperate functions?

novel fern
#

yes

#

if that doesn't work

#

then im not sure

#

cause there seems to be no bugs

formal aurora
#

you dont seem very confident and i dont feel like this is the most efficient way of doing this

#

💀

novel fern
#

i mean

#

if it work

#

it works

formal aurora
#

how is it supposed to tell you when youre NOT jumping or in freefall

novel fern
#

oh so that was the problem

#

alright ill script somthing up

formal aurora
#

tf? 💀

#

oh alrightt

lucid yew
#

nvm

#

hopold on

formal aurora
#

o

#

😭

lucid yew
#

theres some problems with it

novel fern
#

think i found the porblem

#

problem

#

you are using a string

lucid yew
#

what

novel fern
#

when you should be using enum

lucid yew
#

bro get out

novel fern
#

Enum.HumanoidStateType.Jumping

#

like that

#

so state == Enum.HumanoidStateType.Jumping

formal aurora
lucid yew
novel fern
#
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function()
    local State = Humanoid:GetState()
    if State == Enum.HumanoidStateType.Jumping then
        print("falling")
    elseif State == Enum.HumanoidStateType.Freefall then
        print("Landed")
    end
end)```
gilded condorBOT
#

studio** You are now Level 1! **studio

formal aurora
lucid yew
#

hol on

formal aurora
wraith jasper
novel fern
formal aurora
#

i did do that but youre like telling me to split it apart

novel fern
#
local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function()
    local State = Humanoid:GetState()
    if State == Enum.HumanoidStateType.Jumping or Enum.HumanoidStateType.Freefall then
        print("falling")
    else
        print("Landed")
    end
end)```
formal aurora
#

agony THATS WHAT IVE BEEN DOING

novel fern
#

with strings or enum

formal aurora
#

BOTHJ

novel fern
#
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function(State)
    if State == Enum.HumanoidStateType.Jumping or Enum.HumanoidStateType.Freefall then
        print("falling")
    else
        print("Landed")
    end
end)```
#

maybe use the paramater of the event

formal aurora
#

it still dont print landed

#

wtf roblox uhmno

novel fern
#
local Character = script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")

Humanoid.StateChanged:Connect(function(State)
    if State == Enum.HumanoidStateType.Jumping or Enum.HumanoidStateType.Freefall then
        print("falling")
    elseif State == Enum.HumanoidStateType.Landed
        print("Landed")
    end
end)```
formal aurora
#

no can do

novel fern
#

wdym

formal aurora
#

for some reason the state doesnt turn to landed sometimes

wraith jasper
#

Works for me

formal aurora
#

BRO WTF

#

am i supposed to put it in client?

wraith jasper
#

Your using a local script right....

formal aurora
#

💀

novel fern
#

damn

lucid yew
wraith jasper
#

Use a local script and put it in starter character scripts and it will work.

formal aurora
novel fern
#

welp case closed

formal aurora
#

im dead

#

gg

wraith jasper
#

Lmao

formal aurora
#

😭 😭 😭 😭

#

case not closed

#

roblox sucks

#

gg

formal aurora
#

😭

wraith jasper
#

wah

#

Send ss of script

formal aurora
wraith jasper
#

...

#

We have the exact same thing

formal aurora
#

so

#

roblox hates me?

wraith jasper
#

yes saldy

formal aurora
#

bro wtf

#

i dont get it

#

i uninstalled and reinstalled roblox and roblox studio

#

and im getting the same result