API

After you have installed the module. You should know how to use it. Here's the documentation for the module!

RayCast2.new()

initializes the ray to be formed. -> parameters origin [Vector2] or [UDim2] direction [Vector2] or [UDim2] origin: Starting point of the ray direction: Direction point of the ray

-> returns metatable

-> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200))

RayCast2:Cast()

casts the ray in the given direction from the origin -> parameters parent [ScreenGui] whitelist [table]

parent - The screen gui the ray will be parented to, (only if ray.Visible is true) whitelist - This table should contain gui frames/imagelabels that the ray can collide with! -> returns hit [Instance] position [Vector2] hit - The gui the ray collides with position - The point at which the ray collides with the gui

-> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200)) local ScreenGui = path.to.screengui local Hitbox = path.to.guiframe local hit, pos = ray:Cast(ScreenGui, { Hitbox })

Ray.Visible

This property is used to determine if the ray that is created, is visible on the screen! It is set to false by default. -> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200)) ray.Visible = true -- when casting the ray, it will be visible on the screen

RayCast2:GetRayInstance()

Returns the ray guiframe IF ray.Visible is true.

-> returns ray [GuiFrame]

-> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200)) ray.Visible = true -- when casting the ray, it will be visible on the screen local ScreenGui = path.to.screengui local Hitbox = path.to.guiframe game:GetService("RunService").Heartbeat:Connect(function() local hit, pos = ray:Cast(ScreenGui, { Hitbox }) local rayframe = ray:GetRayInstance() rayframe.BackgroundColor3 = Color3.new(1,1,1) end)

RayCast2:GetOrigin()

returns the origin point of the ray -> returns origin [Vector2]

-> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200)) print(ray:GetOrigin())

RayCast2:GetDirection()

returns the direction point of the ray -> returns direction [Vector2]

-> example local RayCast2 = require(path.to.module) local ray = RayCast2.new(Vector2.new(0, 0), Vector2.new(200, 200)) print(ray:GetDirection())

Last updated