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

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

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)

9 comments

0

Does it provide a line number?

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.

0

Sparks Indeed Its At Line

0

14

0

Sparks Idk What You Mean.Sorry Im Just New, Please Explain It Better.Im Really Really Sorry

0

can u tell what is script.parent.parent.parent etc u can directly index it with game.Workspace etc

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

0

I Saved The Edits ThankYou, Now It Still Does Not Work Even Though It Already Syas"game.Players.LocalPlayer"

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!!

1 answer

✓ Accepted answer

Maybe try

local Players = game.Player.LocalPlayer

Or

local Players = game.Players.LocalPlayer

in line 3 Please accept and Upvote if helped!

1 comment

0

client is game.Players.LocalPlayer But Tysm

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