I’ll be quick, I am trying to make a crawl system and I have a raycast to make sure you can’t stand up when you have something above you. My raycast system detects part that are off to the side or not above it. This is a problem.
(Local)Script:
local UserInputService = game:GetService("UserInputService")
local player = script.Parent.Parent
player.CharacterAdded:Wait()
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local crawlAnim = humanoid:LoadAnimation(script.CrawlAnim)
local isCrawling = false
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
if not isCrawling then
humanoid.CameraOffset = Vector3.new(0,-2,0)
character.Head.CanCollide = false
character.PrimaryPart.CanCollide = false
isCrawling = true
crawlAnim:Play()
humanoid.JumpPower = 0
humanoid.WalkSpeed = 9
else
local canStand
local raycastParams = RaycastParams.new()
raycastParams.RespectCanCollide = true
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {character, workspace.building}
canStand = workspace:Raycast(character.PrimaryPart.Position, Vector3.new(character.PrimaryPart.Position.X,character.PrimaryPart.Position.Y+3,character.PrimaryPart.Position.Z),raycastParams)
print(canStand)
if not canStand then
humanoid.CameraOffset = Vector3.new(0,0,0)
character.PrimaryPart.CanCollide = false
character.Head.CanCollide = true
isCrawling = false
crawlAnim:Stop()
humanoid.JumpPower = 50
humanoid.WalkSpeed = 16
end
end
end
end)
Video:
dont mind the error in the output, its from a totally different script