At the moment I'm working on a sword for my game, and I ran into a problem with the sword script. When adding a Debris service to my game, the game casts an error in the output saying, "Unable to cast Instance on double".
blade.Touched:connect(function(hit)
if equipped and character and humanoid and humanoid.Health > 0 and hit and not hit:isDescendantOf(character) then
local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
if targethumanoid and targethumanoid.Health > 0 and not hithumanoids[targethumanoid] then
hithumanoids[targethumanoid] = true
for _, v in pairs(targethumanoid:GetChildren())do
if v and v.Name == "creator" then
v:remove()
end
end
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = player
debris:AddItem(3, tag) -- This is where the output is pointing at
tag.Parent = targethumanoid
targethumanoid:TakeDamage(damage * combo)
p.Data.LevelEXP.Value = p.Data.LevelEXP.Value + 10
end
end
end)
Thank you for reading this.

1 comment
You have the parameters on line 15 switched around.