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

Error attempt to index with nil keeps showing why?

Asked by 3 years ago

This error keeps appearing while it shouldn't Code:

button.MouseButton1Click:Connect(function(plr)
    print(plr.Name)
    if
        script.Parent.Text == "..."
    then

        result.Enabled = true

Error: 18:59:42.616 - Players.probeast0101.PlayerGui.ScreenGui.Frame.Player1.Script:8: attempt to index nil with 'Name'

0
you need to define plr, you can add this line of code into your script instead using plr parameter ~~~~~~~~~~~~~~~~~ local plr = game.Players.LocalPlayer ~~~~~~~~~~~~~~~~~ Blackbooks 138 — 3y
0
This is not your entire code, we can only see 7 lines here User#32819 0 — 3y
0
could you put the entire code? it would be nice to know more so i can attempt to help. youngmacka123 17 — 3y
0
MouseButton1Click event does not return the player as argument, so `plr` is nil like the person said in the comments define plr ~~~~~~~~~~~~~~~~~ local plr = game.Players.LocalPlayer ~~~~~~~~~~~~~~~~~ VerdommeMan 1479 — 3y

Answer this question