So, given the title, Data is not a valid member of Humanoid “GhostHumanoid”. I do know the issue and that it is my script is still looking for the model after it is destroyed, but I am kind of loss in how I could fix this error as it just fills up my output logs. Any help with trying to figure out a method of not having this appear would be greatly appreciated!
if hitPart ~= nil and values.capturable.Value == false then
hitPart.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("GhostHumanoid")
GHumanoid = hit.Parent:FindFirstChild("GhostHumanoid")
if humanoid then
touchingHumanoids[humanoid] = true
end
end)
hitPart.TouchEnded:Connect(function(hit)
GHumanoid = nil
table.clear(touchingHumanoids)
end)
while true do
if GHumanoid then
if GHumanoid.Data.Config.trappable.Value == true then
if hitPart ~= nil and GHumanoid.Health >= 35 then
for humanoid in pairs(touchingHumanoids) do
humanoid:TakeDamage(DAMAGE)
end
end
else
if hitPart ~= nil and GHumanoid.Health >= 0 then
for humanoid in pairs(touchingHumanoids) do
humanoid:TakeDamage(DAMAGE)
end
end
end
task.wait(INTERVAL)
else
break
end
end
end
if hitPart ~= nil and values.capturable.Value == false then
hitPart.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("GhostHumanoid")
GHumanoid = hit.Parent:FindFirstChild("GhostHumanoid")
if humanoid then
touchingHumanoids[humanoid] = true
end
end)
hitPart.TouchEnded:Connect(function(hit)
GHumanoid = nil
table.clear(touchingHumanoids)
end)
while true do
if GHumanoid then
local Data = GHumanoid:FindFirstChild("Data")
if not Data then continue end
local Config = Data:FindFirstChild("Config")
if not Config then continue end
local trappable = Config:FindFirstChild("trappable")
if not trappable then continue end
if trappable.Value == true then
if hitPart ~= nil and GHumanoid.Health >= 35 then
for humanoid in pairs(touchingHumanoids) do
humanoid:TakeDamage(DAMAGE)
end
end
else
if hitPart ~= nil and GHumanoid.Health >= 0 then
for humanoid in pairs(touchingHumanoids) do
humanoid:TakeDamage(DAMAGE)
end
end
end
task.wait(INTERVAL)
else
break
end
end
end