Hello, So I am working on just some scripting practice, and my issue is basically I have a script that when the mousebutton2 is pressed down it will print what the mouse is hovering over, but it wont print,. but I have tried several things and looked at several ways to fix my issue, here is my script
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local TextLabel = game.StarterGui.ObjectNamer.Frame.TextLabel
Mouse.Button1Down:Connect(function()
print("You Clicked Your Mouse!!")
end)
Mouse.Button2Down:Connect(function()
print(Mouse.Target.Name)
TextLabel.Text = Mouse.Target.Name
game.Players.LocalPlayer.PlayerGui.ObjectNamer.Frame.Visible = true
end)
On line 3, youre defining the gui object in starter GUI. This is a universal version of the GUI that gets cloned into each player upon initialization. If you want your GUI to show something, you must access it through game.Players.LocalPlayer.PlayerGui... Let me know if this makes sense.
I redid the code to fit what you said, but now I get a error that says tihs * ObjectNamer is not a valid member of PlayerGui “Players.Kevblx.PlayerGui”* Here is the script and a screenshot of the gui order
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local TextLabel = game.Players.LocalPlayer.PlayerGui.ObjectNamer.Frame.TextLabel
Mouse.Button1Down:Connect(function()
print("You Clicked Your Mouse!!")
end)
Mouse.Button2Down:Connect(function()
print(Mouse.Target.Name)
TextLabel.Text = Mouse.Target.Name
game.Players.LocalPlayer.PlayerGui.ObjectNamer.Frame.Visible = false
end)