local function RayCast(player)
local character = player.Character
if character then
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp then
local rayOrigin = hrp.Position
local rayDirection = Vector3.new(0, -100, 0)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycastResult then
print(player.Name .. " hit:", raycastResult.Instance:GetFullName())
else
print(player.Name .. " ray hit nothing")
end
return raycastResult and raycastResult.Instance == tightRope
end
end
return false
end
#why is raycast not hitting the tightrope even though i am standing on it
1 messages · Page 1 of 1 (latest)
** You are now Level 3! **
@wary jewel
I think the problem is the tightrope isnt collidable.
so the cast couldnt detected it
now this should work:
local function isOnTightRope(player, tightRope)
local character = player.Character
if not character then return false end
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return false end
local origin = hrp.Position + Vector3.new(0, 2, 0)
local direction = Vector3.new(0, -200, 0)
local params = RaycastParams.new()
params.FilterDescendantsInstances = {character}
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(origin, direction, params)
if result then
result:ToDebugDraw({Color = Color3.new(1, 0, 0), Lifetime = 3, Thickness = 0.05})
return result.Instance == tightRope
else
workspace:DebugDrawLine(origin, origin + direction, Color3.new(1, 0, 0), 3)
return false
end
end
** You are now Level 4! **
it is collidable
from tightrope properties
is it in Workspace?
yes
i casted a ray earlier
visually
whenever i touched the tightrope, the ray casted behind me on another
i think we should add some prints so we can understand..
local function isOnTightRope(player, tightRope)
local character = player.Character
if not character then return false end
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return false end
local origin = hrp.Position + Vector3.new(0, 2, 0)
local direction = Vector3.new(0, -200, 0)
local params = RaycastParams.new()
params.FilterDescendantsInstances = { character }
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(origin, direction, params)
if result then
print("Hit:", result.Instance:GetFullName())
result:ToDebugDraw({ Color = Color3.new(1, 0, 0), Lifetime = 3, Thickness = 0.05 })
return result.Instance == tightRope
else
workspace:DebugDrawLine(origin, origin + direction, Color3.new(1, 0, 0), 3)
warn("Missed everything!")
return false
end
end
and send a video or a screenshot
ok..
i saw the problem..
try this:
local RunService = game:GetService("RunService")
local function isOnTightRope(player, tightRope)
local char = player.Character
if not char then return false end
local hrp = char:FindFirstChild("HumanoidRootPart")
if not hrp then return false end
local origin = hrp.Position + Vector3.new(0, 2, 0)
local direction = Vector3.new(0, -200, 0)
local params = RaycastParams.new()
params.FilterDescendantsInstances = {char}
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(origin, direction, params)
if result then
print("Hit:", result.Instance:GetFullName())
workspace:DebugDrawLine(origin, result.Position, Color3.new(1, 0, 0), 3)
return result.Instance == tightRope
else
warn("Missed everything!")
workspace:DebugDrawLine(origin, origin + direction, Color3.new(1, 0, 0), 3)
return false
end
end
local tightRope = workspace:WaitForChild("tightRope")
RunService.Stepped:Connect(function()
for _, player in ipairs(game.Players:GetPlayers()) do
if isOnTightRope(player, tightRope) then
print(player.Name, "is on the rope!")
end
end
end)
the problem was the "ToDebugDraw"
now it should work!
@wary jewel
@wary jewel so?
oh sorry mb i was busy with something else
dont worry
lemme test rq
@frozen abyss
u didnt create the part instance
well-
didnt work like i thought
set part.name wrong
put brackets accidentally
mb
i assigned the name, still same error
@frozen abyss i casted a ray from ai code, it works now
problem was with ray positioning in my old code
oh ok