function Update()
local ClientLadder = ReplicatedStorage:WaitForChild("Ladder"):Clone()
ClientLadder.Parent = LadderPlacedFolder
ClientLadder.Name = Players.Name.."_ladder"
local Render
Render = RunService.RenderStepped:Connect(function()
local Character = Players.LocalPlayer.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Raycastparams = RaycastParams.new()
Raycastparams.FilterType = Enum.RaycastFilterType.Whitelist
Raycastparams.FilterDescendantsInstances = {workspace.Map}
if ClientLadder and HumanoidRootPart then
local Raycast = workspace:Raycast(HumanoidRootPart.Position,(ClientLadder.Main.Position-HumanoidRootPart.Position).Unit*10,Raycastparams)
print(Raycast) -- returns nil
if Raycast ~= nil then
-- do something
end
end
end)
end
Yes, it’s on the wiki:
Casts a ray using an origin, direction, and optional RaycastParams. If it finds an eligible BasePart or Terrain cell, a RaycastResult is returned containing the results of the operation. If no RaycastParams object is provided, the defaults are used (all parts are considered and Terrain water is not ignored).
- WorldRoot | Roblox Creator Documentation
Raycasts return nil when they don’t hit anything.
It appears that your raycasts aren’t hitting anything, so they will return nil.
Another thing to note is that you could just use if raycast
rather than if raycast ~= nil
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.