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

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

Asked by 3 years ago
Edited 3 years ago

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

--Variables--
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!"
--MainScript--
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")
    end)

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

0
Does it provide a line number? Sparks 534 — 3y
0
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 — 3y
0
Sparks Indeed Its At Line Rgboffical_yt 40 — 3y
0
14 Rgboffical_yt 40 — 3y
View all comments (5 more)
0
Sparks Idk What You Mean.Sorry Im Just New, Please Explain It Better.Im Really Really Sorry Rgboffical_yt 40 — 3y
0
can u tell what is script.parent.parent.parent etc u can directly index it with game.Workspace etc panvvan 20 — 3y
0
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 — 3y
0
I Saved The Edits ThankYou, Now It Still Does Not Work Even Though It Already Syas"game.Players.LocalPlayer" Rgboffical_yt 40 — 3y
0
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 — 3y

1 answer

Log in to vote
1
Answered by
iivSnooxy 248 Moderation Voter
3 years ago

Maybe try

local Players = game.Player.LocalPlayer

Or

local Players = game.Players.LocalPlayer

in line 3 Please accept and Upvote if helped!

0
client is game.Players.LocalPlayer But Tysm Rgboffical_yt 40 — 3y
Ad

Answer this question