-
What do you want to achieve? I want to achieve player movement only to where they can see.
-
What is the issue?
The player is supposed to be able to move only where they can see. The player is not supposed to move where the blue squares with x’s are.
-
What solutions have you tried so far?
I’ve tried to move around the code and rearranging what the raycast can target, but it’s still inefficient.
Here’s the script:
for i, clickable in pairs(FPIR) do
local rayParams = RaycastParams.new()
rayParams.FilterDescendantsInstances = {clickable, Map.Blocking}
rayParams.FilterType = Enum.RaycastFilterType.Whitelist
local raycastResult = workspace:Raycast(plr.Character.HumanoidRootPart.Position, clickable.Position, rayParams)
if raycastResult then
local hit = raycastResult.Instance
if hit.Parent.Name == clickable.Parent.Name then
-- If the object that is targeted is hit, create a blue square.
createMoveable(Map, PLACES_TO_MOVE, clickable)
end
else
-- If there is no object hit, create the blue square.
createMoveable(Map, PLACES_TO_MOVE, clickable)
end
end
If you would like a more in-depth explanation, please don’t hesitate to ask.
Anything Helps!