I am trying to create a function that doesn't allow the player to perform something if they are swimming in terrain water.
function build () if Player.Character.Humanoid:GetState(Enum.HumanoidStateType.Swimming) then print "you're not allowed to build that here!" else print "you can build here" end end script.Parent.MouseButton1Click:Connect(build)
The problem is, this make it so "you're not allowed to build that here!" is printed even when the player is not swimming. It always prints that no matter what state the player is in.
How could I make this function work so it only prints if the player is swimming?
Thank you @incapaz, this solution worked.
function build () if Player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Swimming then print "you're not allowed to build that here!" else print "you can build here" end end script.Parent.MouseButton1Click:Connect(build)