I’m not the best at coding but I was trying to make it so that whenever you hover over a object it would display text.
The intended function
This is the code I used
local object = script.Parent
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0, 200, 0, 50)
textLabel.Position = UDim2.new(0, 0, 0, 0)
textLabel.BackgroundTransparency = 0.5
textLabel.BackgroundColor3 = Color3.new(0, 0, 0)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.Text = "Hover Text" -- the text
textLabel.Visible = false
textLabel.Parent = game.Players.LocalPlayer.PlayerGui
object.MouseEnter:Connect(function()
textLabel.Visible = true
end)
object.MouseLeave:Connect(function()
textLabel.Visible = false
end)
I have this in a localscript, which is parented to the cube. the cube is just named “Part” if that matters.
It doesnt work and I’m at a standpoint, any solutions? :3