when the player touch the part, the script will check if the CurrentSword folder is empty, if it is not empty, it clones the sword that is in the folder and if it is empty, clones the classic sword.
The problem is that: it is printing “not Nil”, but the folder is empty.
Does anyone know why?
script.Parent.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
local current = player:WaitForChild("CurrentSword")
if current ~= nil then
print("not nil")
for i, v in pairs(current:GetDescendants()) do
if v:IsA("Tool") then
if not player.Backpack:FindFirstChild(v.Name) then
if not player.Character:FindFirstChild(v.Name) then
v:Clone().Parent = player.Character
end
end
end
end
else
local swords = game.ReplicatedStorage.SHOP.Swords
if not player.Backpack:FindFirstChild("ClassicSword") then
if not player.Character:FindFirstChild("ClassicSword") then
local clone = swords:FindFirstChild("ClassicSword"):Clone()
clone.Parent = player.Character
end
end
end
end
end)