How do you use ray to detect if a model is hanging over the players base when making a placing system?
✓ ANSWER ACCEPTED
How do you use ray for a placing system?
1 answer
✓ Accepted answer
If your model has a Primary Part, you can take that and cast a ray from it, and then check if the part it hits is parented to the players base.
--Sample Code
local playerBase
local modelChecked
local maxDistance = 128 --Or some other number, I don't know.
--Assign all of this
local ray = Ray.new(modelChecked.PrimaryPart.CFrame.p, Vector3.new(0, -1, 0) * maxDistance)
local part, pos = workspace:FindPartOnRay(ray, modelChecked)
if (part.Parent == playerBase) then
--Do whatever you want to do in here
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
