Click detector and script problems

Hello!
I was working on a button that gives you a sword, but its being kind of weird.
It gives me the sword fine, but the click detector icon isn’t showing up. Also, there is some gui hooked up to another script, so when you hover over it with a mouse it should pup up with the gui saying the gears name, but it doesn’t. Here is both of the scripts I made:

The one that is having problems:

local CD = script.Parent.ClickDetector
local GearName = script.Parent:FindFirstChildWhichIsA("StringValue")
local GUI = game.StarterGui.GEARGUI.TextLabel

CD.MouseHoverEnter:Connect(function()
	GUI.Text = GearName.Value
	GUI.Visible = true
end)

CD.MouseHoverLeave:Connect(function()
	GUI.Visible = false
end)

Here is the script that actually gives you the sword: (idk it might be useful)

local CD = script.Parent.ClickDetector
local GearName = script.Parent:FindFirstChildWhichIsA("StringValue")

GearName.Value = script.Parent.Name

local GUI = game.StarterGui.GEARGUI.TextLabel
local Gear = game.ServerStorage.Gears["Classic Sword"]-- Put the name of your gear in the middle of the quotation marks left of this comment <

if Gear.Name == GearName.Value
then
	else
	GUI.Text = "ERROR, check output."
	error("You forgot to change the gear name in the GiveScript for gear giver ".. script.Parent.Name )
end

CD.MouseClick:Connect(function(Player)
	local ClonedGear = Gear:Clone()
	ClonedGear.Parent = Player.Backpack
end)

The problem might be simple, like I just did something wrong. I’m kind of new to scripting, so please tell me if there’s something I can do to fix this.
Thank you to everybody who helps!

1 Like

It should be MouseEnter and

should be MouseLeave.

I changed it and it still doesn’t seem to work…

If you change the StarterGui, it doesn’t affect anything in the view of the player. The StarterGui is only a container that replicates to every player when their character enters the game. So, if you want to change their gui, you have to change it directly, not by using StarterGui.

1 Like
CD.MouseHoverEnter:Connect(function(player)

	local GUI = player.PlayerGui
       if GUI then
           local textLabel = GUI.GEARGUI.TextLabel
           if textLabel then

              textLabel.Text = GearName.Value
              textLabel.Visible = true
           end
      end
end)
1 Like

THANKS! it works now! the click detector symbol still isn’t showing up though… do you think its a glitch?

I think it should work until the detector is parented to a base part, folder or a model. If you can find any useful information, there is the api.

Is it a decal or image you uploaded to Roblox? If so, it might have been moderated because the moderation system is weird.

No, I am just using the default one…