Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Mouse text on hover script Not works why?

I maked a Mouse text on a hover thing for my door but it isn't working the problem is that: Workspace.Mouse Text on hover.Script:6: attempt to index field 'LocalPlayer' (a nil value) And i can't fix it any help? and the script is here: SCRIPT:

local sg = script.Parent:GetChildren()

for i = 1, #sg do
	if sg[i].className == "SurfaceGui" then
		sg[i].TextLabel.MouseEnter:connect(function()
			game.Players.LocalPlayer.PlayerGui.MouseText.NewMouse.Visible = true
			game.Players.LocalPlayer.PlayerGui.MouseText.NewMouse.IconText.Text = script.Parent.TextValue.Value
			sg[i].TextLabel.MouseLeave:connect(function()
				game.Players.LocalPlayer.PlayerGui.MouseText.NewMouse.Visible = false
			end)
		end)
	end
end

I have also a GUI and TextValue. and some more SurfaceGUI but still not works, Anyone help?

2 answers

Make sure that the script is a LocalScript if you wish to use LocalPlayer.

The script should 1) be a localscript to access localplayer and 2) it can't be in workspace to access localplayer, it has to be in the player

2 comments

0

Still, Not works..

0

If it is still not working then you still haven't put it in the Player or PlayerGui.

This discussion is preserved as it was. New answers, comments, and votes are closed.