Server:
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
--// -- // SERVICES // ---- //
local runService = game:GetService("RunService")
local repStorage = game:GetService("ReplicatedStorage")
--// -- // EVENTS // ---- //
local inputEvent = repStorage:WaitForChild("Input")
--// -- // RAYCASTING // ---- //
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
raycastParams.FilterDescendantsInstances = {char}
-- // DISTANCES // --
local distToRCDown = 10
local distToRCSide = 5
local canWallrun = false
-- //// CODE //// -- //
function checkForWallrun()
local rayDirectionDown = Vector3.new(0, -1, 0) * distToRCDown
local rayDirectionLSide = hrp.CFrame.RightVector * -distToRCSide
local rayDirectionRSide = hrp.CFrame.RightVector * distToRCSide
-- Raycast down, left, and right
local raycastResultDown = workspace:Raycast(hrp.Position, rayDirectionDown, raycastParams)
local raycastResultLSide = workspace:Raycast(hrp.Position, rayDirectionLSide, raycastParams)
local raycastResultRSide = workspace:Raycast(hrp.Position, rayDirectionRSide, raycastParams)
if raycastResultDown then
canWallrun = false -- On the ground, cannot wallrun
elseif raycastResultLSide or raycastResultRSide then
canWallrun = true -- Not on the ground, but near a wall
else
canWallrun = false -- Not near a wall or on the ground
end
end
local function checkSec(plr)
if game:GetService("Players"):GetPlayerFromCharacter(char) == plr then
return
else
plr:Kick("Cheater.")
end
end
-- Function to handle input
local function Input(player, input, gpe)
checkSec(player)
print(player.Name)
print(input)
print(gpe)
---- Check if input is a keyboard input
--if input.UserInputType == Enum.UserInputType.Keyboard then
-- -- Now safely check the KeyCode
-- if canWallrun and input.KeyCode == Enum.KeyCode.Space then
-- print("Wallrunning!")
-- end
--end
end
-- Connect the InputBegan event once
inputEvent.OnServerEvent:Connect(Input)
-- Connect to the Heartbeat event for constant updates
runService.Heartbeat:Connect(checkForWallrun)
Local:
local repStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local event = repStorage:WaitForChild("Input")
UIS.InputBegan:Connect(function(input, gpe)
event:FireServer(input, gpe)
end)
For some reason, input is always received as nil (gameprocessed however returns itself normally). Why? It used to work in a different game.