Log in to vote

[SOLVED]attempt to index nil with 'Rgboffical_yt' How Do I Fix This?

Asked by 6 months ago
Edited 6 months ago

so it keeps giving me a error saying: attempt to index nil with 'Players' How Do I Fix It? here is The Code

local client = game.Players.LocalPlayer
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")--gets ReplicatedStorage
local ServerStorage = game:GetService("ServerStorage")--get ServerStorage
local ToolsFolder = ReplicatedStorage:FindFirstChild("Tools")-- gets the tools folder
local InventoriesFolder = ServerStorage:FindFirstChild("Inventories")-- gets the inventories folder
local button = script.Parent-- gets the button
local SpeedCoil = ToolsFolder:FindFirstChild("SpeedCoil")
print("VariablesDone!")--prints "VariablesDone!"
button.MouseButton1Click:Connect(function()--when a player presses the button in left click
    print("Pressed")-- when a player presses the button then it will print out "Pressed"
    local inventory_folder = InventoriesFolder[client.Name]
    print("No Errror BRUH")
    SpeedCoil:Clone().Parent = inventory_folder
    print("No Errror BRUH2")
    SpeedCoil:Clone().Parent = client.Backpack
    print("No Errror BRUH3")
    SpeedCoil:Clone().Parent = client.StarterGear
    print("No Errror BRUH4")

Thanks!! (Someone Solved It So Local Scripts Cant Acess ServerStorage So Yea TYSM To That Guy/Girl I Forgot Hers/His Name)

Does it provide a line number? Sparks 534 — 6mo
From this code, it seems you are not indexing anything from Players so I am not sure this is the snippet of code you should be showing. Sparks 534 — 6mo
Sparks Indeed Its At Line Rgboffical_yt 40 — 6mo
14 Rgboffical_yt 40 — 6mo
View all comments (5 more)
Sparks Idk What You Mean.Sorry Im Just New, Please Explain It Better.Im Really Really Sorry Rgboffical_yt 40 — 6mo
can u tell what is script.parent.parent.parent etc u can directly index it with game.Workspace etc panvvan 20 — 6mo
Ohhhhh yea , im sorry i got the wrong variable But Its Supposed To Be "game.Players.LocalPlayer" Im Really Sorry I Copied The Wrong Variable Im Rlly Sorry Rgboffical_yt 40 — 6mo
I Saved The Edits ThankYou, Now It Still Does Not Work Even Though It Already Syas"game.Players.LocalPlayer" Rgboffical_yt 40 — 6mo
Sparks it Still does Not work I Changed It To "local client = game.Players.LocalPlayer" And Gave Me A new Error Saying " : attempt to index nil with 'Rgboffical_yt' " Please Help ThankYou!! Rgboffical_yt 40 — 6mo

1 answer

Log in to vote
Answered by
iivSnooxy 248 Moderation Voter
6 months ago

Maybe try

local Players = game.Player.LocalPlayer


local Players = game.Players.LocalPlayer

in line 3 Please accept and Upvote if helped!

client is game.Players.LocalPlayer But Tysm Rgboffical_yt 40 — 6mo

Answer this question