Skip to content

Basic Usage

After following the steps in Getting Started, we can now implent it into our games!

Creating a DynamicCrosshair

Creating Crosshair
local UI : ScreenGui = script.Parent 
local DynamicCrosshair = require(script.DynamicCrosshair).New(UI)
DynamicCrosshair:Enable()

-- DynamicCrosshair.New() takes 6 different arguments
--[[ 
DynamicCrosshair.New(
    Ui, MinSpread, MaxSpread, 
    DecreasePerSecond, IncreasePerSecond, Follow Mouse
)
]]--
Warning

For the module to work, you must call the DynamicCrosshair:Enable() function

Crosshair Movement

DynamicCrosshair supports various ways to move our crosshair, lets see some of these ways:

Crosshair Set
Setting The Radius
1
2
3
4
5
6
local UI : ScreenGui = ...
local DynamicCrosshair = require(...).New(UI)
DynamicCrosshair:Enable()

DynamicCrosshair:Set(40)
DynamicCrosshair:Set('60')

In this video, for example purposes the :Set() function is called 3 times with a radius parameter of 60

Note

DynamicCrosshair's :Set() function has a very simular look to :Shove(), but they have different behaviors.

If you want :Set() to permantly set the radius of the crosshair, look toward using :Lock() or set the radius minimum.

Crosshair Smooth Set

DynamicCrosshair's SmoothSet() function uses Roblox's TweenService to tween the crosshair's radius to a final goal.

Setting The Radius
local UI : ScreenGui = ...
local DynamicCrosshair = require(...).New(UI)
DynamicCrosshair:Enable()

-- Set tweening style and direction

DynamicCrosshair.EasingStyle = Enum.EasingStyle.Sine -- default: linear
DynamicCrosshair.EasingDirection = Enum.EasingStyle.In -- default: InOut

-- DynamicCrosshair:SmoothSet(Spread, Transition Seconds, Update Minimum Radius When Completed)
DynamicCrosshair:SmoothSet(40, 1, false)
DynamicCrosshair:SmoothSet(40, 1)
DynamicCrosshair:SmoothSet(40, 1, nil)

In this video, for example purposes the :Set() function is called 3 times with a radius parameter of 60

Crosshair Shove

Bug

DynamicCrosshair's :Shove() is currently experiencing odd behaviors, should be fixed soon. It is suggested to use :Set() to replace :Shove() until it is fixed.

DynamicCrosshair crosshair shove will "shove" the crosshair's radius based on Spreading.IncreasePerSecond

Shove Example
1
2
3
4
5
6
7
local UI : ScreenGui = script.Parent 
local DynamicCrosshair = require(script.DynamicCrosshair).New(UI)
DynamicCrosshair:Enable()

DynamicCrosshair.Spreading.IncreasePerSecond = 30

DynamicCrosshair:Shove()

Crosshair Customization

If you are looking to customize the looks of the crosshair, please visit Display Customization

Follow Mouse
Follow Mouse Example
1
2
3
4
5
6
7
local UI : ScreenGui = script.Parent 
local DynamicCrosshair = require(script.DynamicCrosshair).New(UI)
DynamicCrosshair:Enable()

-- DynamicCrosshair:FollowMouse(boolean)
DynamicCrosshair:FollowMouse(true)
DynamicCrosshair:FollowMouse(false)
Lock The Crosshair

Locking the crosshair will lock out the crosshair's radius from decreasing at all, until enabled again.

Follow Mouse Example
1
2
3
4
5
6
7
8
local UI : ScreenGui = script.Parent 
local DynamicCrosshair = require(script.DynamicCrosshair).New(UI)
DynamicCrosshair:Enable()

-- DynamicCrosshair:Lock(boolean)
DynamicCrosshair:Lock() -- locked is true
DynamicCrosshair:Lock(true) -- locked is true
DynamicCrosshair:Lock(false) -- locked is false

Next Steps

Go Visit: Display Customization | Raycasting | Hitmarkers