Can't get crosshair script to work

Ive been working on a game and I have a third person gun system and I want it so when you pull the gun out the crosshair shows up but it hasn’t been working im not sure why ive tried putting it in different places and everything


-- local crosshair = script.Parent.Crosshair
local isGunEquipped = false

-- Function to show the crosshair
local function showCrosshair()
	crosshair.Visible = true
end

-- Function to hide the crosshair
local function hideCrosshair()
	crosshair.Visible = false
end

-- Function to handle changes in gun equipment
local function handleGunEquipment(isEquipped)
	if isEquipped then
		-- Show crosshair when any gun is equipped
		showCrosshair()
	else
		-- Hide crosshair when no gun is equipped
		hideCrosshair()
	end
end

-- Connect gun events to the crosshair system
game.GlockEXT.Equipped:Connect(function()
	handleGunEquipment(true)
end)

game.GlcokEXT.Unequipped:Connect(function()
	handleGunEquipment(false)
end)

Check the console just once.

image

Glcok

image
your crosshair is in a tool, not the playergui

image
you’re not even referencing the object because the tool is in workspace and not game

Was this script made with ChatGPT?

1 Like

yeah theres comments before every function made or fired obviously it was made by ai

Yeah the guy who made the gun system quit so it was unfinished

Im not sure how to fix this can you explain how

yeah sure here’s a youtube tutorial for you because i’m not in the mood for writing a paragraph today