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)
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.