If Statement wont Print [CLOSED]

Put it in the OnTouched function

1 Like

its printing when i hit the wall

  16:47:47.301  LowerTorso  -  Client - wall jump:19
  16:47:47.301  Wall  -  Client - wall jump:19
  16:47:47.301  RightUpperLeg  -  Client - wall jump:19
  16:47:47.301  HumanoidRootPart  -  Client - wall jump:19
  16:47:47.301  UpperTorso  -  Client - wall jump:19
  16:47:47.301  LeftUpperLeg  -  Client - wall jump:19

Yes, but as I assumed. It’s hitting the player as well.

Also that would be your reason for it printing false, because most of the times the touched objects will be your Character and not the wall.

So this bit here

if otherPart.Name ~= "Wall" then
		TouchingWall = false
	end

won’t work at filtering only the walls?

1 Like

Yes you are on the wall at some point, but you also have that in there making it false. Reply to me so I can say what I need to please. I just said absolute bull, And it won’t let me post lol

1 Like

test2.rbxl (143.7 KB)
here is the wold so it is easier to see what is messing up. if that helps

Okay, so let me restart this whole thing. Basically you need to use the GetTouchingParts.

You need to check if “Wall” is inside the TouchingParts table, It saves a lot of confusion. I’m not trying to get you to use a RayCast, Because even I struggle with them. This would be the better way I assume to do this.

2 Likes

Ok, I’m pretty sure I understand now. I will try this out

1 Like

I’m not sure if this makes an error for the value not being in the table, but this is a shorter way of checking if it’s in the table or not.

if not table.find(part:GetTouchingParts(), "Wall") then 
end

-- Or either this because it returns nil if it's not in the table --

if table.find(part:GetTouchingParts(), "Wall") == nil then
end
1 Like

Do this:

local UIS = game:GetService("UserInputService")
local char = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Colider = char.Collider
local TouchingWall = false
local NotOnGround = true
local Humanoid = Character:WaitForChild("Humanoid")
slide = Instance.new("BodyVelocity")
Dismount = Instance.new("BodyVelocity")
WallSlide = false

----------------------------------------------------- TOUCHING WALL

local part = char.Collider
local function onTouched(otherPart)
	if otherPart.Name == "Wall" then
		TouchingWall = true
	end
	if otherPart.Name ~= "Wall" then
		TouchingWall = false
	end
	--print("TouchingWall",TouchingWall)
end

local function onTouchEnded(part)
	TouchingWall = false
	--print("TouchingWall",TouchingWall)
end

part.Touched:Connect(onTouched)
part.TouchEnded:Connect(onTouchEnded)

----------------------------------------------------- TOUCHING GROUND

task.spawn(function()
while true do
	if Humanoid.FloorMaterial == Enum.Material.Air then
			NotOnGround = true
	else
			NotOnGround = false
	end
		--print("NotOnGround",NotOnGround)
		wait()
	end
end)

----------------------------------------------------- GROUND & WALL

if NotOnGround == true and TouchingWall == true then
	WallSlide = true
	print("WallSlide",WallSlide)
else
	WallSlide = false
	print("WallSlide",WallSlide)
end

if NotOnGround Already returns true just so you know.

-- Example --
local Bool = true

while true do
end

-- Is the same as --

while Bool do
end
1 Like

Then do this:

local UIS = game:GetService("UserInputService")
local char = script.Parent
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Colider = char.Collider
local TouchingWall = false
local NotOnGround = true
local Humanoid = Character:WaitForChild("Humanoid")
slide = Instance.new("BodyVelocity")
Dismount = Instance.new("BodyVelocity")
WallSlide = false

----------------------------------------------------- TOUCHING WALL

local part = char.Collider
local function onTouched(otherPart)
	if otherPart.Name == "Wall" then
		TouchingWall = true
	end
	if otherPart.Name ~= "Wall" then
		TouchingWall = false
	end
	--print("TouchingWall",TouchingWall)
end

local function onTouchEnded(part)
	TouchingWall = false
	--print("TouchingWall",TouchingWall)
end

part.Touched:Connect(onTouched)
part.TouchEnded:Connect(onTouchEnded)

----------------------------------------------------- TOUCHING GROUND

task.spawn(function()
while true do
	if Humanoid.FloorMaterial == Enum.Material.Air then
			NotOnGround = true
	else
			NotOnGround = false
	end
		--print("NotOnGround",NotOnGround)
		wait()
	end

	if NotOnGround == true and TouchingWall == true then
		WallSlide = true
		print("WallSlide",WallSlide)
	else
		WallSlide = false
		print("WallSlide",WallSlide)
	end
end)

Also, we already found the issue, and it doesn’t have anything to do with the code necessarily (The part you’re talking about), Just the collider part.

1 Like
part = char.Collider


	if table.find(part:GetTouchingParts(), "Wall") == nil then
	
	TouchingWall = false
else
	TouchingWall = true
	
	end

is not working

Ok then just try, I don’t remember too much about tables. I’m more of a Javascript person, In which tables are much simpler than lua. So I get them mixed up most of the time.

local TouchingParts = part:GetTouchingParts()

if not TouchingParts["Wall"] then
 TouchingWall = false
else
  TouchingWall = true
end
1 Like
part = char.Collider


if table.find(part:GetTouchingParts(), "Wall") == nil then

	local TouchingParts = part:GetTouchingParts()

	if not TouchingParts["Wall"] then
		TouchingWall = false
		print("TouchingWall",TouchingWall)
	else
		TouchingWall = true
		print("TouchingWall",TouchingWall)
	end

end

not printing anything except false when Starting the game

Are you Touching a wall? (3-0 characters)

1 Like

no, but even when i do, nothing is printed at all

Oh, I meant to remove the table.find thing and replace it with if not TouchingParts[“Wall”]

1 Like