Crosshair Service (Make Dynamic Crosshairs With Ease)

What Is Crosshair Service?


Crosshair service is a module with a goal. That goal is to make creating dynamic crosshairs easy. Whenever I would scrub the developer forum It would always come to my attention that there were not many / no competent crosshair-related resources out there. This is the reason why I created Crosshair Service I want a competent crosshair-related resource that the developer community can benefit freely from.

Why Should I Use Crosshair Service


  • Performant
    Crosshair Service is highly performant this is because Crosshair Service only uses renderstepped to update the mouse position and uses Tween Service for animating the crosshair.

  • Easy To Use
    Crosshair Service is easy to use because of the fact that it is designed from the ground up as an object-oriented module. Furthermore, it is easy to use because it has a simple versatile API.

  • Efficient
    Crosshair Service is efficient because of the fact that it allows developers to spend their time on other things instead of creating a crosshair system/module.

  • Third Person Support
    Unlike other crosshair related resources, Crosshair Service supports the third person. This can be important if you are making a first/third-person framework or a strictly third-person framework.

  • Open Source
    Crosshair Service is fully open source. This means that anyone has the right and ability to completely modify our code to their needs. Furthermore, this ensures that developers can trust Crosshair Service as a safe nonmalicious module as they have full access to the source code.

Getting Started (Important)


  • How Can I Obtain Crosshair Service
    The only current and official source to obtain Crosshair Service is the Roblox toolbox. Crosshair Service - Roblox

  • Step #1: Put The Module Instead Of Replicated Storage
    image

  • Step #2: Use The Template ScreenGUI
    Note: The Template ScreenGUI was borrowed from FE GUN KIT.
    It is important that you study or use the template ScreenGUI this is because of the fact that the template ScreenGUI that contains the crosshair is structured in a way that is compatible with Crosshair Service. In this example I will be adding the template ScreenGUI to StarterGUI.
    image

API (Important)


CrosshairService.new(MainFrame : Frame, Radius : number, EasingStyle : Enum.EasingStyle, EasingDirection : Enum.EasingDirection, Lerp : number) -- This function is for creating a new crosshair object

CrosshairService:Set(Radius : number, Can_Animate : boolean, EasingStyle : Enum.EasingStyle, EasingDirection : Enum.EasingDirection, Lerp : number) -- This function is for setting the radius of the crosshair
CrosshairService:Shove(Radius : number, EasingStyle : Enum.EasingStyle, EasingDirection : Enum.EasingDirection, Lerp : number) -- this function is for shoving the crosshair to a specific radius

CrosshairService:Freeze() -- This function is for freezing the crosshair's position
CrosshairService:UnFreeze() -- This function is for unfreezing the crosshair's position

CrosshairService:Enable() -- This function is for enabling the crosshair object
CrosshairService:Disable() -- This function is for disabling the crosshair object
CrosshairService:Destroy() -- This function is for destroying the crosshair object

Notes


  • When creating a new crosshair with Crosshair Service call the enable function for it to take effect.

  • It is important that if you want to remove a crosshair you call the destroy function

Examples


Script Example


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserinputService = game:GetService("UserInputService")
local CrosshairService = require(ReplicatedStorage:WaitForChild("CrosshairService"))
local Mouse = game:GetService("Players").LocalPlayer:GetMouse()

-- Crosshair
local Crosshair = CrosshairService.new(script.Parent.Crosshair, 10)
Crosshair:Enable()

Mouse.Button1Down:Connect(function()
	Crosshair:Shove(Crosshair.Radius * 3.5)
end)

Misc


  • I will be answering replies to this post for support on implementing Crosshair Service.

  • I will be implementing feature requests.

  • Stay tuned for more modules in the future.

41 Likes

There’s another similar ones that I’ve found already but are you willing to add Single image support which scales when the crosshair shoves???

I love using this type of Crosshair instead of using the default.
5df788bc4b115e62137d9d1e52360fe4a97e9727

4 Likes

For sure I will add singlar image scale support. As I want to provide to the needs of the community. I think that single image support would be a great idea because everyone overlooks it.

3 Likes

Is there any way to control the raycast inside of it? Isn’t there a :Raycast function?

3 Likes

I can add one it would be pretty simple.

1 Like

would be awesome if you do so. make sure that the raycast is with in the radius

2 Likes

The crosshair is not at the center of the mouse but instead under the mouse. the link is a video because the upload button did not work i had to share the video with a link.

Make sure IgnoreGuiInset is enabled on your crosshair ScreenGui.

image

1 Like

it works but how can i make it that the crosshair is in the middle of the screen on mobile ?

1 Like

I can make a mobile update for the module if u want me to

4 Likes

that would be nice if you could do that but no pressure i allready found a temporary solution to this problem but its not great.

Is there a way to Get whats inside the crosshair, can be usefull for making “dynamic” spread

1 Like

Hey, i hope it is okay if i modify you’re module to my liking, i made the crosshair smoother when opening up

1 Like

That’s a really nice edition I am glad that you have made it, in response to getting what is inside of the crosshair yes I could add some code to do it, But just for a basis you could ray cast from the center dot of the crosshair and do some calculations to add spread.

1 Like

Where do i put the script for making the corsshair? ( Not the module )


Why is my crosshair acting like this?