[v1.5] Create Dynamic Crosshairs! (Updated!)

I also having a problem with smooth set function . It just doesn’t tween

Can you send some examples? (code, videos, images, errors, etc)

if hum.WalkSpeed == 15 then
		task.spawn(function()
			Crosshairmodule:Lock(true)
			Crosshairmodule:SmoothSet(50,2)
		end)
         -- other stuff
    end

this is basically it .
the problem is just it doesn’t tween . all I can say its like using the Set() function instead of SmoothSet()

Any errors? I’m not sure why this wouldn’t work, maybe the module is broken? Can you test the smooth set function is other places of your code?

there is no errors and I use the latest version of module.But I required the module in the StarterCharacterScripts instead of StarterGui

the center dot does not go away if i type CenterDot.enabled = false

Huh weird works perfectly with me:

https://gyazo.com/98a658f9c834acbe22d2bfb6586d833b

Code
local DynamicCrosshair = require(game.ReplicatedStorage.DynamicCrosshair)

local crosshair = DynamicCrosshair.New(script.Parent)

crosshair:Enable()

while true do
	crosshair.CenterDot.enabled = true
	print('Enabled')
	task.wait(1)
	crosshair.CenterDot.enabled = false
	print('Disabled')
	task.wait(1)
end

Try updating to the current module version along with making sure there are no errors in your code, if not send your code so I can see for my self.

It seems like the module was broken :sweat_smile:

It was a type… whoops

Update to newest here: DynamicCrosshair - Roblox (FIXED)

1 Like

no it still wont work, and now the whole crosshair goes away and there is an error in the Module: ReplicatedStorage.DynamicCrosshair:238: attempt to index nil with ‘AbsoluteSize’.

This is my localscript:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mouse = plr:GetMouse()

local cas = game:GetService("ContextActionService")
local TweenService = game:GetService("TweenService")
local InputService = game:GetService("UserInputService")

local GunGui = plr.PlayerGui:FindFirstChild("GunGui")

local EasyFP = char:WaitForChild("EasyFirstPerson")
local defaulAimOffset = nil

if EasyFP then
	defaulAimOffset = EasyFP:WaitForChild("AimOffset").Value
end

local DCM = require(game.ReplicatedStorage.DynamicCrosshair)
local Crosshair = DCM.New(GunGui)

local AimingOffset = Vector3.new(0,-0.15,-0.15)
local InAimTweenInfo = TweenInfo.new(0.2,Enum.EasingStyle.Quint,Enum.EasingDirection.Out)
local OutAimTweenInfo = TweenInfo.new(0.2,Enum.EasingStyle.Quint,Enum.EasingDirection.In)

local InAimTween = TweenService:Create(EasyFP:FindFirstChild("AimOffset"),InAimTweenInfo,{["Value"] = AimingOffset})
local OutAimTween = TweenService:Create(EasyFP:FindFirstChild("AimOffset"),OutAimTweenInfo,{["Value"] = defaulAimOffset})

local tool = script.Parent

local idleAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.IdleAnim)
local shootAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.ShootAnim)
local aimAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.AimAnim)
local aimShootAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.AimShootAnim)

local isAiming = false
local isEquipped = false

tool.Equipped:Connect(function()
	
	Crosshair:Enable()
	Crosshair.CenterDot.enabled = true
	
	isEquipped = true
	
	script.Parent.BodyAttach.EquipSound:Play()

	game.ReplicatedStorage.ConnectM6D:FireServer(tool.BodyAttach)
	
	char:FindFirstChild("Right Arm").ToolGrip.Part0 = char:FindFirstChild("Right Arm")
	char:FindFirstChild("Right Arm").ToolGrip.Part1 = tool.BodyAttach
	
	
	idleAnim:Play()
end)

tool.Unequipped:Connect(function()
	
	Crosshair:Disable()
	Crosshair.CenterDot.enabled = false
	
	isEquipped = false

	game.ReplicatedStorage.DisconnectM6D:FireServer()
	
	idleAnim:Stop()
end)

local function aimIn()
	isAiming = true
	Crosshair:Disable()
	aimAnim:Play()
	idleAnim:Stop()
	InAimTween:Play()
end

local function aimOut()
	isAiming = false
	idleAnim:Play()
	aimAnim:Stop()
	OutAimTween:Play()
	if isEquipped == true then
		Crosshair:Enable()
	end
end

mouse.Button2Down:Connect(function()
	aimIn()
end)
mouse.Button2Up:Connect(function()
	aimOut()
end)

tool.Activated:Connect(function()
	script.Parent.BodyAttach.ShootSound:Play()
	if isAiming == true then
		aimShootAnim:Play()
	else
		shootAnim:Play()
	end
end)

Try putting the CenterDot line before the :Disable() function

i can not test it out because not even the crosshair gets created because there is a bug in the modulescript in the Update function on line 238 its says: attempt to index nil with ‘AbsoluteSize’

In that case, it is saying the UI is nil or doesn’t exist

plr.PlayerGui:FindFirstChild("GunGui") <-- maybe this is nil?

Your issue isn’t the module’s doing

omg i changed it to waitforchild and now it works. whats the point of findfirstchild i thought thats almost the same thing. but the CenterPoint will still not go away.

:FindFirstChild() finds the child with that name and if it doesn’t exist it’ll not error, instead everything else will

1 Like

Your module script is very great! But I do have a suggestion. Maybe you can make a function call where it stops all tweens. Maybe you can make this, DynamicCrosshair:StopAllTweens() and this, DynamicCrosshair:PauseAllTweens().

1 Like

Could you explain the functionality of that suggestion and when you would use it in scripting? If it is a good idea I can add it to the next update

Words can’t express how helpful this module is. Dynamic crosshair module is my most liked module of every other I’ve seen on the devforum. Im happy to see the developer still working on the project. Thank you very much <3

1 Like

When I set the crosshair to follow mouse (By using :followmouse(true)), The cross hair isn’t allined with the mouse at all.

Make sure to have the latest version of the module, and IgnoreGuiInset turned off. If the issue still persists please provide screenshots and code examples.

1 Like

The link to your module’s documentation seems to be broken.
I tried searching in your GitHub repositories, but you have none in your name…

Would it be possible for you to bring it back up again?

5 Likes