So i’m trying to parent a script from a replicatedstorage to a button but it says "attempt to index nil with ‘Parent’ " how can i fix this
I dont wanna do clone because it will clone a script more than once
local slotcheck = game.ReplicatedStorage.SlotCheck:Clone()
local slot1 = game.ReplicatedStorage.SlotScripts:FindFirstChild("Slot1")
local slot2 = game.ReplicatedStorage.SlotScripts:FindFirstChild("Slot2")
local slot3 = game.ReplicatedStorage.SlotScripts:FindFirstChild("Slot3")
local slot4 = game.ReplicatedStorage.SlotScripts:FindFirstChild("Slot4")
UISlot.Parent = player.PlayerGui.MainMenu.Main
UISlot.Name = "Slot"..i
UISlot.Position = UDim2.new(0.398, 0, (0.054 + (0.170 * (i - 1))), 0)
UISlot.PlrName.Text = FirstName.." "..LastName
UISlot.Level.Text = "Lvl. "..Level
UISlot.Race.Text = Race
if slotcheck then
if player:FindFirstChild("DataSlot1") and player.PlayerGui.MainMenu.Main:FindFirstChild("Slot1") then
slotcheck.Name = 'Dataslot1'
slot1.Parent = player.PlayerGui.MainMenu.Main:FindFirstChild("Slot1")
slotcheck.Parent = player:FindFirstChild("DataSlot1")
end
if player:FindFirstChild("DataSlot2") and player.PlayerGui.MainMenu.Main:FindFirstChild("Slot2") then
slotcheck.Name = 'Dataslot2'
slotcheck.Parent = player:FindFirstChild("DataSlot2")
slot2.Parent = player.PlayerGui.MainMenu.Main:FindFirstChild("Slot2")
end
if player:FindFirstChild("DataSlot3")and player.PlayerGui.MainMenu.Main:FindFirstChild("Slot3") then
slotcheck.Name = 'Dataslot3'
slotcheck.Parent = player:FindFirstChild("DataSlot3")
slot3.Parent = player.PlayerGui.MainMenu.Main:FindFirstChild("Slot3")
end
if player:FindFirstChild("DataSlot4") and player.PlayerGui.MainMenu.Main:FindFirstChild("Slot4") then
slotcheck.Name = 'Dataslot4'
slotcheck.Parent = player:FindFirstChild("DataSlot4")
slot4.Parent = player.PlayerGui.MainMenu.Main:FindFirstChild("Slot4")
end