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.
Nvm, I actually found out the line
debris:AddItem(3, tag)
had to be switched to
debris:AddItem(tag, 3)
This may have been switched due to Roblox lua updating since I followed an old tutorial.