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

A StarterGear Nil Value?

local plr = game.Players.LocalPlayer
local foil = plr.Backpack:FindFirstChild("LinkedSword3").Handle.Mesh
local foil2 = plr.StarterGear:FindFirstChild("LinkedSword3").Handle.Mesh


script.Parent.MouseButton1Click:Connect(function()
	if foil.TextureId == ("rbxassetid://2150176816") or foil2.TextureId == ("rbxassetid://2150176816") then
		
		print ("Already Has This Item")
	else
		
		if plr.leaderstats.Wins.Value>=5 then
			foil.TextureId = ("rbxassetid://2150176816")
			foil2.TextureId = ("rbxassetid://2150176816")
	
               
			else
			print ("Does Not Have Enough Wins")
		end
	end
end)

".LocalScript:3: attempt to index a nil value 19:26:13.576 - Stack Begin"

StarterGear is a nil value? Its a shop that switches sword textures. The whole script works without the startergear, but when you reset it goes back to normal, which is why I want to include startergear. Thanks ~innhale

1 comment

0

Where is StarterGear being created, It's most likely getting made after this script.

1 answer

local plr = game.Players.LocalPlayer
local foil = plr.Backpack:FindFirstChild("LinkedSword3").Handle.Mesh
local foil2 = plr:WaitForChild("StarterGear"):FindFirstChild("LinkedSword3").Handle.Mesh


script.Parent.MouseButton1Click:Connect(function()
    if foil.TextureId == ("rbxassetid://2150176816") or foil2.TextureId == ("rbxassetid://2150176816") then

        print ("Already Has This Item")
    else

        if plr.leaderstats.Wins.Value>=5 then
            foil.TextureId = ("rbxassetid://2150176816")
            foil2.TextureId = ("rbxassetid://2150176816")


            else
            print ("Does Not Have Enough Wins")
        end
    end
end)

The StarterGear Folder is most likely being created after this script is being run so it's not showing up. I have added a WaitForChild to the Starter Gear Folder, let me know if this works.

1 comment

0

it comes out with the same error

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