• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


29 Nov, 2024

Updated at 13 Dec, 2024

Raycast/Mouse help

Trying to make it so that my raycast ignores all can collidable parts.

I made it ignore it in the raycast, however it for some reason like because the mouse still sees the collidable part, it disorts it and gives me this weird issue. I want to figure out how to raycast to where the mouse is clicked and ignore certain parts completely.

Heres a video:
https://i.gyazo.com/00a3770476c0eb973a0397b580a2ce23.mp4

Code:

function Framework:Raycast(Origin, EndPos, IgnoreList, Range, CallCheck, MaxRunTimes, RunTimes)
	local Params = RaycastParams.new();
	local Distance = (EndPos - Origin).unit;
	local RayResults 

	Params.FilterType = Enum.RaycastFilterType.Exclude;
	Params.IgnoreWater = true;
	Params.FilterDescendantsInstances = IgnoreList; -- includes the collideable part

	RayResults = workspace:Raycast(Origin, Distance * Range, Params);

    return RayResults
end

--  how its called
local RayResults = self:Raycast(self.Tool.Main.CFrame.p, Vector3.new(mousePos.x + (math.random() * (spread * 2) - spread), mousePos.y + (math.random() * (spread * 2) - spread), mousePos.z + (math.random() * (spread * 2) - spread)), self:GetIgnoreList(game.Players.LocalPlayer.Character), self.Config.Range and self.Config.Range or 500, function(RayResults)
	if RayResults.Instance:IsDescendantOf(workspace.Assets.Interactables.Vehicles) then return false end

	if RayResults.Instance.CanCollide == false or RayResults.Instance.Transparency == 1 then 
		return true
	end

	if RayResults.Instance:IsDescendantOf(workspace.CurrentCamera) then 
		return true 
	end

	return false
end, self.Config.MaxRetries and self.Config.MaxRetries or 10)

1 post - 1 participant

Read full topic