So me and my friend have just gotten into scripting and we followed this tutorial on how to make a simple attack and how to make it do damage. Our problem is that we cant do damage for some reason. Can someone please tell us what we did wrong in our script? we checked multiple times and we really cant figure out what is wrong.
Thanks in advance!
Local script:Player = game.Players.LocalPlayer Mouse = Player:GetMouse()
Mouse.KeyDown:connect (function(key) key = key:lower() if key == "f" then local x = Instance.new("Part", workspace) x.Shape = "Ball" x.BrickColor = BrickColor.new("White") x.Transparency = 0.5 x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.CFrame = Player.Character.UpperTorso.CFrame * CFrame.new(0,-1,-6) local v = Instance.new("BodyVelocity", x) v.velocity = Player.Character.UpperTorso.CFrame.LookVector * 90 v.maxForce = Vector3.new (math.huge, math.huge, math.huge) local f = Instance.new("Fire") f.Size = 10 f.Parent = x
local S = script("script"):clone() S.Disabled = false S.Parent = x x.Parent = workspace
wait(2) x:remove()
end
end)
the script that is inside the local script:
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")~= nil then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 20 script.Parent:remove() end
end)

2 comments
Put it in a regular script, or/and use remote functions to hurt the player when fired.
make sure to use the code block