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

How can I reform my damage function?

Asked by 6 years ago
Edited 6 years ago

Hi, I'm Goodbye_Fx.

What would be the error-free way of modifying the damage script on line 20-22?

16:10:23.137 - Humanoid is not a valid member of Workspace 16:10:23.138 - Stack Begin 16:10:23.139 - Script 'Workspace.BluePlasma Event', Line 21 16:10:23.139 - Stack End

game.Workspace.BluePlasma.OnServerEvent:Connect(function(Player, animation, Debounce)
    local AlreadyTouched = false
    local Character = Player.Character or Player.CharacterAdded:wait()
    Debounce = true
    local BluePlasma = Instance.new("Part")
    BluePlasma.Name = "BluePlasma"
    BluePlasma.Shape = Enum.PartType.Ball
    wait(0.5)
    BluePlasma.Size = Vector3.new(2,2,2)
    BluePlasma.Material = Enum.Material.Neon
    BluePlasma.BrickColor = BrickColor.Blue()
    BluePlasma.CanCollide =  false
    BluePlasma.Parent = Character
    BluePlasma.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-6)
    local bv = Instance.new("BodyVelocity")
    bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    bv.Velocity = Character.HumanoidRootPart.CFrame.lookVector*70
    bv.Parent = BluePlasma

    BluePlasma.Touched:Connect(function(Hit)
        if Hit and Hit.Parent.Humanoid then
            Hit.Parent.Humanoid:TakeDamage(5)
        end
    end)
    wait(1)
    BluePlasma:Destroy()
    Debounce = false
end)
0
For me this one is good, but you can create the Plasma on studio, ando not on the script =D Leamir 3138 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You had some mistakes in your script, heres your fixed script:

game.Workspace.BluePlasma.OnServerEvent:Connect(function(Player, animation, Debounce)
    local AlreadyTouched = false
    local Character = Player.Character or Player.CharacterAdded:wait()
    Debounce = true
    local BluePlasma = Instance.new("Part")
    BluePlasma.Name = "BluePlasma"
    BluePlasma.Shape = Enum.PartType.Ball
    wait(0.5)
    BluePlasma.Size = Vector3.new(2,2,2)
    BluePlasma.Material = Enum.Material.Neon
    BluePlasma.BrickColor = BrickColor.Blue()
    BluePlasma.CanCollide =  false
    BluePlasma.Parent = Character
    BluePlasma.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(0,1,-6)
    local bv = Instance.new("BodyVelocity")
    bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    bv.Velocity = Character.HumanoidRootPart.CFrame.lookVector*70
    bv.Parent = BluePlasma

    BluePlasma.Touched:Connect(function(Hit)
        if Hit.Parent:FindFirstChild("Humanoid") then
            Hit.Parent.Humanoid:TakeDamage(5)
        end
    end)
    wait(1)
    BluePlasma:Destroy()
    Debounce = false
end)

The main issues was the code block:

BluePlasma.Touched:Connect(function(Hit)
    >    if Hit and Hit.Parent.Humanoid then
            Hit.Parent.Humanoid:TakeDamage(5)
        end
    end)

in the second sentence Marked with a ">" in the line of code, your saying if Hit.Parent.Humanoid is not nil, but the thing is Your asking referencing something that isnt there when the plasma touches a non-humanoid object.

0
If this SOMEHOW didnt work, please tell me and Ill try re-looking at it. HeComesAt_Night 116 — 6y
0
no man Goodbye_Fx 29 — 6y
Ad

Answer this question