Help Me With My TDX Range Circle Mechanic

hello Developers,I Have Made An Range Circle Which Is Similar To The TDX Range Circle But I Have Only Done The RayCast Handling I Don’t Know How To Actually Draw It Here Is My Ray Handling Script:

local part = workspace.Target1
local RunService = game:GetService("RunService")

local numRays = 36 

RunService.PostSimulation:Connect(function(deltasim)
	for i = 1, numRays do
		local angle = math.rad(i * (360 / numRays))

		local startCFrame = part.CFrame * CFrame.Angles(0, angle, 0)
		local direction = startCFrame.LookVector.Unit * 200

		local RaycastResult = workspace:Raycast(part.Position, direction, nil, {part})

		if RaycastResult then
			local hitInstance = RaycastResult.Instance
			print("Detected:", hitInstance.Name)
		end
	end
end)

im asking for someone to help me along with the drawing(im not asking for full scripts)

https://www.youtube.com/watch?v=1JyiBmB7Fvw&t=18s watch the start of the video this is what i am trying to achieve.

2 Likes

No One Helps This Is So Sad:(…

1 Like

ok soo i have draw a circle but i have a few problems when i collide with the range it disappears but there is a short delay and the ray sometimes detects parts that are far away and this problem


please help

1 Like

I have actually made this recently, all you need to use is triangles, however I am currently revamping it

can you help me with it because i can’t figure it out.

make a wedge that looks like a triangle. 3 defined points

ok i will make it in blender here it is :

ok what after?


I made this. Then used code from this to work it out

local wedge = Instance.new("WedgePart");
wedge.Anchored = true;
wedge.TopSurface = Enum.SurfaceType.Smooth;
wedge.BottomSurface = Enum.SurfaceType.Smooth;

local function draw3dTriangle(a, b, c, parent, w1, w2)
	local ab, ac, bc = b - a, c - a, c - b;
	local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);
	
	if (abd > acd and abd > bcd) then
		c, a = a, c;
	elseif (acd > bcd and acd > abd) then
		a, b = b, a;
	end
	
	ab, ac, bc = b - a, c - a, c - b;
	
	local right = ac:Cross(ab).unit;
	local up = bc:Cross(right).unit;
	local back = bc.unit;
	
	local height = math.abs(ab:Dot(up));
	
	w1 = w1 or wedge:Clone();
	w1.Size = Vector3.new(0, height, math.abs(ab:Dot(back)));
	w1.CFrame = CFrame.fromMatrix((a + b)/2, right, up, back);
	w1.Parent = parent;
	
	w2 = w2 or edge:Clone();
	w2.Size = Vector3.new(0, height, math.abs(ac:Dot(back)));
	w2.CFrame = CFrame.fromMatrix((a + c)/2, -right, up, -back);
	w2.Parent = parent;
	
	return w1, w2;
end
1 Like

I knew how to draw the circle but I don’t get how they make it act like it is raycasted I need help on that.

1 Like

bro its a raycast. The making of the triangle is the hardest

2 Likes

Sorry But I Am New To Scripting So I Think That The RayCast Part Is The Hardest lol.


with your helpful code made this but i don’t get how would i ray cast this

here is my code i used your function tho i need help on the raycasting part.

1 Like

please send me you full code. I need to look at it.

1 Like

Ok Thank you For Your Handy Function


i have made it but now i need to figure out how to constantly update it Thank You By The Way.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.