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!