Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Object Expected,Got String What happened?

Asked by 3 years ago

Output: 22:21:40.541 - Workspace.BookOfTragedy.Part.Firedamage:7: bad argument #3 (Object expected, got string) 22:21:40.542 - Stack Begin 22:21:40.542 - Script 'Workspace.BookOfTragedy.Part.Firedamage', Line 7 - function onDamage 22:21:40.542 - Stack End

Debris = game:GetService("Debris")
function onDamage(Part)
    if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then
        script.Disabled = true
        local Creator_Tag = Instance.new("ObjectValue")
    Creator_Tag.Name = "creator"
    Creator_Tag.Value = script.Parent.Name
    Debris:AddItem(Creator_Tag, 2)
    Creator_Tag.Parent = Part.Parent.Character.Humanoid
        for i = 1,40 do
            Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -6.5
            a = Instance.new("Part")
            a.BrickColor = BrickColor.new("Really black")
            a.Material = "Plastic"
            a.Transparency = "1"
            a.Size = Vector3.new(1,1,1)
            a.CanCollide = false
            a.Parent = Part.Parent.Torso
            a.CFrame = Part.Parent.Torso.CFrame
            a.TopSurface = "Smooth"
            a.BottomSurface = "Smooth"
            a.Name = "Effect"
            am = Instance.new("SpecialMesh")
            am.MeshType = "Sphere"
            am.Scale = Vector3.new(11,11,11)
            am.Parent =  a
            local weld = Instance.new("Weld", game.JointsService)
            weld.Part0 = Part.Parent.Torso
            weld.Part1 = a
            weld.C0 = CFrame.new(0,0,0)
            weld.C1 = CFrame.new(0,0,0)
            wait(0.05)
            if Part.Parent.Torso:findFirstChild("Effect")
            then a:Destroy()
            wait(0.003)
            elseif Part.Parent.Torso:findFirstChild("Effect")~= nil
            then return end
        end
        script.Parent:Destroy()
    end
    wait(0.025)
end

script.Parent.Touched:connect(onDamage)

1 answer

Log in to vote
2
Answered by 3 years ago

Just remove the .Name on line 7. Object values use actual instances instead of object names (strings). This should work:

local Debris = game:GetService("Debris")

local function onDamage(Part)
    if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent.Name ~= "script.Parent.Name" then
        script.Disabled = true
        local Creator_Tag = Instance.new("ObjectValue")
    Creator_Tag.Name = "creator"
    Creator_Tag.Value = script.Parent
    Debris:AddItem(Creator_Tag, 2)
    Creator_Tag.Parent = Part.Parent.Character.Humanoid
        for i = 1,40 do
            Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -6.5
            a = Instance.new("Part")
            a.BrickColor = BrickColor.new("Really black")
            a.Material = "Plastic"
            a.Transparency = "1"
            a.Size = Vector3.new(1,1,1)
            a.CanCollide = false
            a.Parent = Part.Parent.Torso
            a.CFrame = Part.Parent.Torso.CFrame
            a.TopSurface = "Smooth"
            a.BottomSurface = "Smooth"
            a.Name = "Effect"
            am = Instance.new("SpecialMesh")
            am.MeshType = "Sphere"
            am.Scale = Vector3.new(11,11,11)
            am.Parent =  a
            local weld = Instance.new("Weld", game.JointsService)
            weld.Part0 = Part.Parent.Torso
            weld.Part1 = a
            weld.C0 = CFrame.new(0,0,0)
            weld.C1 = CFrame.new(0,0,0)
            wait(0.05)
            if Part.Parent.Torso:findFirstChild("Effect")
            then a:Destroy()
            wait(0.003)
            elseif Part.Parent.Torso:findFirstChild("Effect")~= nil
            then return end
        end
        script.Parent:Destroy()
    end
    wait(0.025)
end

script.Parent.Touched:Connect(onDamage)

Ad

Answer this question