# Example

Head into Roblox Studio!\
\
Create a Frame and name it "Box". Set its AnchorPoint to 0.5, 0.5 and set its position to:\
`UDim2.new(0.827, 0, 0.499, 0)`

![](https://602295869-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mhms8gN-uvchlIwntnZ%2F-Mhn23Z3iUIWYKqcQyfe%2F-Mhn3OMQz4RWksmt_MFo%2Fimage.png?alt=media\&token=68bb7e97-12ab-43ac-b977-4d896a8f68fb)

Now create a LocalScript, lets get coding!\
\
I also added a Folder named "Points". Which will contain our Intersection point frames.

![](https://602295869-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mhms8gN-uvchlIwntnZ%2F-Mhn23Z3iUIWYKqcQyfe%2F-Mhn5vpUl369f6zR-Bq2%2Fimage.png?alt=media\&token=3773cdf5-5ac9-4f7e-a12d-67fd270f5b04)

Here's the code in our LocalScript!

`local RayCast2 = require(path.to.module)`\
`local Box = script.Parent`\
`local ScreenGui = script.Parent.Parent`\
\
`game:GetService("RunService").Heartbeat:Connect(function()`\
&#x20;  `Box.Rotation += 0.2`\
&#x20;  `ScreenGui.Points:ClearAllChildren()`\
\
&#x20;  `local ray = RayCast2.new(Vector2.new(0, 225), Vector2.new(500, 225))`\
&#x20;  `ray.Visible = true`\
\
&#x20;  `local hit, pos= ray:Cast(ScreenGui, {Box})`\
\
&#x20;  `if hit and pointPosition then`\
&#x20;    `local pointFrame = Instance.new("Frame")`\
&#x20;    `pointFrame.Name = "Point"`\
&#x20;    `pointFrame.BackgroundColor3 = Color3.new(255, 0, 0)`\
&#x20;    `pointFrame.Size = UDim2.new(0, 10, 0, 10)`\
&#x20;    `pointFrame.AnchorPoint = Vector2.new(.5, .5)`\
&#x20;    `pointFrame.Position = UDim2.new(0, pos.X, 0, pos.Y)`\
&#x20;    `pointFrame.ZIndex = 2`\
&#x20;    `pointFrame.Parent = ScreenGui.Points`\
&#x20;  `end`\
`end)`\
\
Result (Screenshot)

![](https://602295869-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Mhms8gN-uvchlIwntnZ%2F-Mhn71e1DVokqIXgnWzJ%2F-Mhn8IvJVWFmby_vwerP%2Fimage.png?alt=media\&token=c694ca8e-5410-4841-a277-2989f3178cc0)

The red point frame will always be located at the point of intersection of the ray and the Box frame!
