function MouseEntered() local T = game.Players:GetPlayerFromCharacter(MouseEntered.Parent).PlayerGui.ScreenGui.Cursor.Text T.Text = T.text.new("a") T.Visible = true end function MouseLeft() local T = game.Players:GetPlayerFromCharacter(MouseLeft.Parent).PlayerGui.ScreenGui.Cursor.Text T.Text = T.text.new("Lable") T.Visible = false end script.Parent.ClickDetector.MouseHoverEnter:connect(MouseEntered) script.Parent.ClickDetector.MouseHoverLeave:connect(MouseLeft)
It says
20:41:25.192 - Workspace.object.food.Script:24: attempt to index global 'MouseLeft' (a function value)
20:41:25.192 - Workspace.object.food.Script:24: attempt to index global 'MouseEntered' (a function value)
Your mistake here is you're attempting to recieve the player incorrectly. You're indexing the function name's Parent. There is no such thing because it is a function, hence your errors.
The MouseHoverEnter
, and MouseHoverLeave
events both return the player that interacted with the object. This returned value can be accessed using parameters! Parameters are what you put in the parenthesis while defining a function.
So, access the player this way and you should be good. Or at least see some response from the event.
Other than that, you're changing the text wrong. Just directly set the 'Text' property.
function MouseEntered(player) --You can access the player now local T = player.PlayerGui.ScreenGui.Cursor T.Text = "a" T.Visible = true end function MouseLeft(player) local T = player.PlayerGui.ScreenGui.Cursor T.Text = "Label" T.Visible = false end script.Parent.ClickDetector.MouseHoverEnter:connect(MouseEntered) script.Parent.ClickDetector.MouseHoverLeave:connect(MouseLeft)
You have it so you are trying to get "MouseEntered.Parent" when that isn't exactly how it works. In this case you would want to use the built in parameter for the MouseHoverEnter and Leave. I personally like to keep my calling of the function and the actual function together so it would look like this:
script.Parent.ClickDetector.MouseHoverEnter:connect(function(player)-- This gets the player and activates when the mouse enters local Cursor = player.PlayerGui.ScreenGui.Cursor -- You can just use player.PlayerGui because of the parameter which gets the player Cursor.Text = "a" -- I'm guessing this is what you are trying to do? Cursor.Visible = true end) script.Parent.ClickDetector.MouseHoverLeave:connect(function(player) local Cursor = player.PlayerGui.ScreenGui.Cursor Cursor.Text = "Lable" -- Again just a guess of what you are trying to do Cursor.Visible = false end)
If I helped answer your question then please remember to accept my answer. If not, then please message me or comment on how I could have done better to help. :)