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
(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
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)