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

23:54:35.755 Argument 1 missing or nil error? making projectile.

Asked by 2 years ago
Edited by Xapelize 2 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

i need help with an error, when making my projectile it keeps saying, 23:54:35.755 Argument 1 missing or nil, and i've tried to fix the problem many times but it wouldnt work.

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, character)
    local char = player.Character or player.CharacterAdded:Wait()
    local root = character:WaitForChild("HumanoidRootPart")
    local fbtime = 4

    local MuseProjectile = game.ReplicatedStorage.Part:Clone()
    MuseProjectile.Parent = workspace
    MuseProjectile.CFrame = root.CFrame * CFrame.new (0,0,-2)
    game.Debris:AddItem(MuseProjectile, fbtime)

    local bodyvel = Instance.new("BodyVelocity")
    bodyvel.MaxForce = Vector3.new(1e8, 1e8,1e8)
    bodyvel.Velocity = root.CFrame.LookVector * 80
    bodyvel.Parent = MuseProjectile

    local debounce = false
    MuseProjectile.Touched:Connect(function(hit)
        if hit.isDescendantOf(char) then
            return
        end

        if hit.Parent:IsA("Accoutrement") then
            hit = hit.Parent
        end

        local enemyhumanoid = hit.Parent:WaitForChild("Humanoid")
        local enemyroot = hit.Parent:WaitForChild("HumanoidRootPart")
        if enemyhumanoid and not debounce then
            debounce = true
            MuseProjectile:Destroy()
            local HitM = game.ReplicatedStorage.Fire:Clone()
            HitM.Parent = enemyroot
            spawn(function()
                wait(.5)
                HitM.Enabled = false
                wait(.6)
                HitM.Destroy()
            end)
            enemyhumanoid:TakeDamage(25)
            wait()
            debounce = false
        end
    end)
end) 
1
Learn to format your code and share the full output properly for assistance. NotFrindow 346 — 2y

2 answers

Log in to vote
1
Answered by 2 years ago

In line 17, you should use colon when using functions like Instance:IsDescendantOf()

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player, character)
    local char = player.Character or player.CharacterAdded:Wait()
    local root = character:WaitForChild("HumanoidRootPart")
    local fbtime = 4
    local MuseProjectile = game.ReplicatedStorage.Part:Clone()
    MuseProjectile.Parent = workspace
    MuseProjectile.CFrame = root.CFrame * CFrame.new (0,0,-2)
    game.Debris:AddItem(MuseProjectile, fbtime)

    local bodyvel = Instance.new("BodyVelocity")
    bodyvel.MaxForce = Vector3.new(1e8, 1e8,1e8)
    bodyvel.Velocity = root.CFrame.LookVector * 80
    bodyvel.Parent = MuseProjectile

    local debounce = false
    MuseProjectile.Touched:Connect(function(hit)
        if hit:IsDescendantOf(char) then -- line that had the error
            return
        end

        if hit.Parent:IsA("Accoutrement") then
            hit = hit.Parent
        end

        local enemyhumanoid = hit.Parent:WaitForChild("Humanoid")
        local enemyroot = hit.Parent:WaitForChild("HumanoidRootPart")
        if enemyhumanoid and not debounce then
            debounce = true
            MuseProjectile:Destroy()
            local HitM = game.ReplicatedStorage.Fire:Clone()
            HitM.Parent = enemyroot
            task.spawn(function()
                task.wait(.5)
                HitM.Enabled = false
                task.wait(.6)
                HitM.Destroy()
            end)
            enemyhumanoid:TakeDamage(25)
            task.wait()
            debounce = false
        end
    end)
end)
0
what is colon? FallenAngel_ii 7 — 2y
0
colon is : T3_MasterGamer 2189 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

If you are using Instance.IsDescendantOf(), you have to specify the instance itself, like

--These two are the same
Instance.IsDescendantOf(Instance, char)
Instance:IsDescendantOf(char)

it automatically passes itself, useful for object-oriented programming

Answer this question