When entering a part, the script will supposedly detect what the hasCloned bool’s value is. If it is false then it would have to clone the tool and if true it just sets its parent back to the player backpack (somewhere in my script I just set its parent elsewhere just in case the player will use it again). When tested, the script wouldn’t work, the tool doesn’t get cloned at all and also doesn’t go the player’s backpack nor character and it prompts attempt to index nil with ‘parent’ in the output. Help pls
CODE:
--using ZonePlus module--
zone1.playerEntered:Connect(function(Player)
if Debounce == false then
Debounce = true
local char = Player.Character or Player.CharacterAdded:Wait()
local toolClone
if not char:FindFirstChild(Tool.Name) then
if not hasCloned then
toolClone = Tool:Clone()
toolClone.Parent = Player.Backpack
toolClone.Name = Tool.Name
local toolOwnerTag = Instance.new("IntValue", toolClone)
toolOwnerTag.Name = "ToolOwnerTag"
toolOwnerTag.Value = Player.UserId
hasCloned = true
if not table.find(ffaAreaTouchers, Player.UserId) then
table.insert(ffaAreaTouchers, Player.UserId)
end
elseif hasCloned then
if toolClone.Parent ~= Player.Backpack then
toolClone.Parent = Player.Backpack
local toolOwnerTag = toolClone:FindFirstChild("ToolOwnerTag")
toolOwnerTag.Value = Player.UserId
if not table.find(ffaAreaTouchers, Player.UserId) then
table.insert(ffaAreaTouchers, Player.UserId)
end
end
end
end
task.wait(Cooldown_Time)
Debounce = false
end
end)