Okay so I want to do a damage script with a NumberValue but for some reason it kills the dummy I'm testing the move on,can someone tell me where I did wrong? Here's the script
wait(3)
local debounce = false
Player = script.Parent.Parent.Parent
n = script.Parent
mouse = Player:GetMouse()
run = game:GetService("RunService")
duh = 0
function pizza(mouse)
if debounce == false then
debounce = true
local x = Instance.new("Part")
x.Shape = "Ball"
x.Anchored = true
x.CanCollide = false
x.Reflectance = 0
x.Transparency = 1
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
x.Parent = Workspace
x.Size = Vector3.new(270.05, 70.48, 289.81)
x.BrickColor = BrickColor.new("White")
x.Name = Player.Name
x.Parent = Workspace
x.CFrame = Player.Character.Torso.CFrame *CFrame.new(0, -3, 0)
local x1 = Instance.new("Part")
x1.Shape = "Ball"
x1.Anchored = true
x1.CanCollide = false
x1.Reflectance = 0.1
x1.Transparency = 0.8
x1.TopSurface = "Smooth"
x1.BottomSurface = "Smooth"
x1.Parent = Workspace
x1.Size = Vector3.new(150, 150, 150)
x1.BrickColor = BrickColor.new("White")
x1.Name = Player.Name
x1.Parent = Workspace
x1.CFrame = Player.Character.Torso.CFrame *CFrame.new(0, -3, 0)
m = Instance.new("SpecialMesh", x1)
m.MeshType = "Sphere"
m.Scale = Vector3.new(2, 1, 2)
x.Touched:connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent:FindFirstChild("Humanoid") ~= Player.Character.Humanoid then
for i, v in pairs(Part.Parent:GetChildren()) do
if v:IsA("NumberValue") and v.Name == "damage" then return
else
damage = Instance.new("NumberValue", Part.Parent)
damage.Value = 30
Part.Parent.Humanoid.Health = Part.Parent.Humanoid.Health -damage.Value
Part.Parent.Humanoid.Sit = true
wait(0.1)
Part.Parent.Torso.Velocity = Vector3.new(math.random(-500,500),650,math.random(-500,500))
end
end
end
wait(0.025)
end)
game.Debris:AddItem(x, 5)
game.Debris:AddItem(x1, 5)
wait(60)
debounce = false
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function() pizza(mouse) end)
end
n.Selected:connect(onSelected)

1 comment
Thanks, one more question, if I test it on 2 dummys, only one takes the damage and flings, how to make so like everyone flings and takes damage?