I am making an equip script for my survival game, but the input keeps telling me that there is a nil value.
ServerScriptService.Main:156: attempt to index a nil value
I tried things ranging from repeat wait() just to make sure it was actually there, and WaitForChild, but it still comes up as nil for some reason. it makes me really confused too because a line before it detected it, but then all of a sudden it becomes nil...
Script:
local function Equip1(p)
repeat wait() until game.ServerStorage.Items:FindFirstChild(p.PlayerGui.Inventory.Frame.Slot1.TextLabel.Text)
p.Stats.ItemEquipped.Value = true
local item = game.ServerStorage.Items:FindFirstChild(p.PlayerGui.Inventory.Frame.Slot1.TextLabel.Text):Clone()
print(item.Name)
item.Parent = game.Players.LocalPlayer.Character
item.CFrame = item.Parent.RightHand.CFrame
local weld = Instance.new("Weld", item.Parent.RightHand)
weld.Part0 = item.Parent.RightHand
weld.Part1 = item
item.Anchored = false
weld.C0 = CFrame.new(0,-.3,-1)
end
game.ReplicatedStorage.Events.Equip.Slot1.OnServerEvent:Connect(Equip1)
If you know why this is then please tell me so. Thanks!

8 comments
Output*, not input lol
You can edit questions, y'know.
Also, where is your monitor at? ROBLOX's servers or your pc?
it was on my pc. I was in studio and did a Local Server test, and thats what happened
Wheres the full script?
^ that is the full server script...But i noticed i added local player to it accidently, so i removed that, and now nothing shows inside of the output and nothing works. I am very confused now
That is certainly not the full script, your error is referencing an error on line 156 so it isn't possible for it to be an error in a 19 line script.
That part of the script has nothing to do with this part. his part of the script is just equipping, the other part is un-equipping. So they do not really affect each other.