If Statement wont Print [CLOSED]

I want WallSlide to turn on or off if NotGround and TouchWall are on. I don’t know what the issue is but it will print false on running the game and won’t do anything else. I’ve tried to move things around but can’t find a solution that works

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 and TouchingWall == true then
	WallSlide = true
	print("WallSlide",WallSlide)
else
	WallSlide = false
	print("WallSlide",WallSlide)
end
	

I believe that to check if they are on the ground, is not Enum.Material.Air but that there is no FloorMaterial. This might be your issue?

if not Humanoid.FloorMaterial then
end

no i printed the ground segment and it worked fine

Try using this and printing the FloorMaterial

Humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    print(Humanoid.FloorMaterial)
end)
  16:23:23.439  Enum.Material.Plastic  -  Client - wall jump:59
  16:23:23.738  Enum.Material.Air - Client - wall jump:59

With print(“NotOnGround”,NotOnGround) what are you trying to do with the variable NotOnGround?

Also, I would use this instead of the While true loop

it prints the name of the Varriable + if its true of false, so it would look like this in the output NotOnGround True

1 Like

Does the NotOnGround and TouchWall part work fine?

yes they do
(i need to type 3-0 characters)

Then I believe that your issue is coming from the .Touched and .TouchEnded itself, it’s been known to be very sensitive to literally anything

Try commenting the prints for those

What is char.Collider??, is it a part you created?

they have been commented since OP

Yes its a ring around humanoid part since raycasting in a ring is painful to my noob brain

3 Likes

Any errors tho? As @FentTamer said, there’s something fishy in the final lines of the code.

(BasePart:GetTouchingParts) Try printing this as the BasePart to be the “Collider” And the part also might be touching the character itself, Which may be why it’s doing that. So I might have to assume that you would need to use a RayCast to Blacklist the Character. Although I don’t know where it is, I’m just assuming

1 Like

I can’t figure out how to print that, How should I format it?

for i, part in part:GetTouchingParts() do
   print(part.Name)
end
1 Like

its not printing anything


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

for i, part in part:GetTouchingParts() do
	print(part.Name)                                         ---------Here is the code you sent
end

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