So basically, I've been making this attack script and I really need this damage thing to work, here's what I got right now, it's meant to work but doesn't. Can anyone please hint out the mistake?
part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") ~= nil then if hit.Parent.Name ~= Player.Name then hit.Parent.Humanoid:TakeDamage(math.huge) end end end)
Is this what you meant?
local playername = "tantec" -- name of the player NOT to deal damage to. script.Parent.Touched:Connect(function(hit) for i,v in pairs(game.Players:GetPlayers())do if v and v.Character and v.Character:IsAncestorOf(hit) then if v.Name:lower() ~= playername:lower() then v.Character:BreakJoints() end end end end)
part should be defined so maybe put the script under the part and use script.Parent
don't use :connect instead use :Connect
~=nil is also not needed and you shouldn't use hit.Parent~=Player.Name instead, just use if hit.Parent:FindFirstChild("Humanoid") then
math.huge is an infinite value so you can just do max damage or a certain integer hit.Parent.Humanoid.Health = 0
your script should end up like
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:FindFirstChild("Humanoid").Health = 0 end end)