What I want is when the mouse hovers over the door, an image label is visible at the mouse.
--//Main game:GetService("RunService").RenderStepped:connect(function() local X = Mouse.X -- mouse x axis local Y = Mouse.Y -- mouse y axis if Mouse.Target then if Mouse.Target.Name == "Door1" or "Door2" or "Door3" or "Door4" then print("Mouse has closet as target") hover.Visible = true hover.Position = UDim2.new(0, X -50, 0, Y-50) else hover.Visible = false end end end)
The code does not work. It only works when I set Mouse.Target.Name to only one name (ex. "Door1"). But when I use "Door1" or "Door2" or ....., it never works. Why is that?
game:GetService("RunService").RenderStepped:connect(function() local X = Mouse.X -- mouse x axis local Y = Mouse.Y -- mouse y axis if Mouse.Target then if Mouse.Target.Name == "Door1" or Mouse.Target.Name == "Door2" or Mouse.Target.Name == "Door3" or Mouse.Target.Name == "Door3" then print("Mouse has closet as target") hover.Visible = true hover.Position = UDim2.new(0, X -50, 0, Y-50) else hover.Visible = false end end end)
The initial script wouldn't work because three of the expressions are just strings, and not conditional.