I’ve started to learn how to code in “Lua” or Roblox’s version of it so bear with me. I have a script I’m working on wor wall sliding and jumping like in ultra kill, but the issue is that after line 50 I cannot execute any more code
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
--stuff
local part = char.Collider
local function onTouched(otherPart)
--print(part.Name .. " collided with " .. otherPart.Name)
if otherPart.Name == "Wall" then
TouchingWall = true
--print("Touching wall")
else
TouchingWall = false
--print("NOT Touching Wall")
end
end
part.Touched:Connect(onTouched)
while true do
if Humanoid.FloorMaterial == Enum.Material.Air then
--print("NOT on ground")
NotOnGround = true
else
--print("on ground")
NotOnGround = false
end
wait()
if NotOnGround and TouchingWall == true then
WallSlide = true
else
WallSlide = false
end
end
I have tried moving things around and trying to compress the code, but I can’t come up with a working solution. hence why I’m looking to the community for help
Here is a link to the world if anybody needs it Test.rbxl (143.4 KB)
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
--stuff
local part = char.Collider
local function onTouched(otherPart)
--print(part.Name .. " collided with " .. otherPart.Name)
if otherPart.Name == "Wall" then
TouchingWall = true
--print("Touching wall")
else
TouchingWall = false
--print("NOT Touching Wall")
end
end
part.Touched:Connect(onTouched)
task.spawn(function()
while true do
if Humanoid.FloorMaterial == Enum.Material.Air then
--print("NOT on ground")
NotOnGround = true
else
--print("on ground")
NotOnGround = false
end
wait()
if NotOnGround and TouchingWall == true then
WallSlide = true
else
WallSlide = false
end
end
end)
the problem wasn’t actually in end) it was that you needed to use task.spawn() to run the while loop on a separate thread so it doesn’t yield the code after it.