Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Mouse text on hover script Not works why?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago

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

0
Still, Not works.. Minekaft153 -15 — 5y
0
If it is still not working then you still haven't put it in the Player or PlayerGui. RealTRG 0 — 5y

Answer this question