Ello Developers!
I made this script Inside of a tool that looks like one of the gloves In SB, (Slap Battles), Anyway, Currently, I want to know If the tool will damage players that are not In a team, here Is the script:
local Tool = script.Parent local CanDamage = false Tool.RemoteEvent.OnServerEvent:Connect(function() CanDamage = true Tool.Handle.Swing:Play() local SwingAnim = Tool.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Tool.Animation) SwingAnim:Play() Tool["Da glove"].Touched:Connect(function(hit) local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if Player then local player1 = game.Players:GetPlayerFromCharacter(hit.Parent) local player2 = game.Players:GetPlayerFromCharacter(Tool.Parent) if (player1 ~= nil) and (player2 ~= nil) then local humanoid = (player1.Character or player1.CharacterAdded:Wait()):FindFirstChildWhichIsA("Humanoid") if (player1.TeamColor ~= player2.TeamColor) then if (humanoid ~= nil) and CanDamage == true then Tool.Handle.Hit:Play() humanoid:TakeDamage(35) CanDamage = false if not humanoid.Parent.Torso:FindFirstChild("VectorForce") then local KnockBack = Instance.new("VectorForce") local Attachment = Instance.new("Attachment") KnockBack.Parent = humanoid.Parent.Torso Attachment.Parent = humanoid.Parent.Torso KnockBack.Attachment0 = Attachment KnockBack.ApplyAtCenterOfMass = true KnockBack.Force = Vector3.new(0,300,6000) humanoid.Jump = true game:GetService("Debris"):AddItem(KnockBack,0.5) game:GetService("Debris"):AddItem(Attachment,0.5) local RagdollScript = script.Ragdoll:Clone() game:GetService("Debris"):AddItem(RagdollScript,4) RagdollScript.Parent = humanoid.Parent RagdollScript.Enabled = true end end --This Is the part I am unsure of--- elseif (player1.Team ~= game.Teams) then Tool.Handle.Hit:Play() humanoid:TakeDamage(35) CanDamage = false if not humanoid.Parent.Torso:FindFirstChild("VectorForce") then local KnockBack = Instance.new("VectorForce") local Attachment = Instance.new("Attachment") KnockBack.Parent = humanoid.Parent.Torso Attachment.Parent = humanoid.Parent.Torso KnockBack.Attachment0 = Attachment KnockBack.ApplyAtCenterOfMass = true KnockBack.Force = Vector3.new(0,300,6000) humanoid.Jump = true game:GetService("Debris"):AddItem(KnockBack,0.5) game:GetService("Debris"):AddItem(Attachment,0.5) local RagdollScript = script.Ragdoll:Clone() game:GetService("Debris"):AddItem(RagdollScript,4) RagdollScript.Parent = humanoid.Parent RagdollScript.Enabled = true end end end --end-- elseif not Player then local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid and CanDamage == true then Tool.Handle.Hit:Play() humanoid:TakeDamage(35) CanDamage = false if not humanoid.Parent.Torso:FindFirstChild("VectorForce") then local KnockBack = Instance.new("VectorForce") local Attachment = Instance.new("Attachment") KnockBack.Parent = humanoid.Parent.Torso Attachment.Parent = humanoid.Parent.Torso KnockBack.Attachment0 = Attachment KnockBack.ApplyAtCenterOfMass = true KnockBack.Force = Vector3.new(0,300,6000) humanoid.Jump = true game:GetService("Debris"):AddItem(KnockBack,0.5) game:GetService("Debris"):AddItem(Attachment,0.5) local RagdollScript = script.Ragdoll:Clone() game:GetService("Debris"):AddItem(RagdollScript,4) RagdollScript.Parent = humanoid.Parent RagdollScript.Enabled = true end end end end) wait(1) CanDamage = false end) Tool.Ability1Event.OnServerEvent:Connect(function() local Build = Tool.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Tool.Building) Build:Play() wait(0.10) local ROOMBA = game:GetService("ReplicatedStorage").TrollRoomba:Clone() game:GetService("Debris"):AddItem(ROOMBA,60) ROOMBA.Parent = game.Workspace ROOMBA.Position = Tool.Parent.Torso.Position ROOMBA.Orientation = Tool.Parent.Torso.Orientation ROOMBA.CFrame = ROOMBA.CFrame + (ROOMBA.CFrame.LookVector*5) ROOMBA.Owner.Value = Tool.Parent.Name ROOMBA.Roomba.Touch.Enabled = false ROOMBA.Roomba.Position = ROOMBA.Position ROOMBA.Roomba.CFrame = ROOMBA.Roomba.CFrame * CFrame.new(0,1,0) ROOMBA.WeldConstraint.Part0 = ROOMBA ROOMBA.WeldConstraint.Part1 = ROOMBA.Roomba wait(2) ROOMBA.Roomba.Touch.Enabled = true ROOMBA.VectorForce.Force = Vector3.new(1300,0,0) end) Tool.Ability2Event.OnServerEvent:Connect(function() local ZAP = Tool.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(Tool.Zap) ZAP:Play() wait(0.30) Tool.Handle.Beep:Play() wait(0.19) for i=0, Tool.ROOMBASTODESTROY.Value do local CurrentRoombas = game.Workspace:GetChildren() for _, Roomba in ipairs(CurrentRoombas) do if Roomba:FindFirstChild("Owner") then game:GetService("Debris"):AddItem(Roomba,2) if Roomba.Owner.Value == Tool.Parent.Name then Roomba.Anchored = true Roomba.Roomba.Touch.Enabled = false Roomba.Roomba.Transparency = 1 Roomba.Roomba.Beam:Destroy() local ExplosionSound = Tool.Handle.Explosion:Clone() ExplosionSound.Parent = Roomba ExplosionSound:Play() local KABOOOOOOOOOOOOM = Instance.new("Explosion",game.Workspace) game:GetService("Debris"):AddItem(KABOOOOOOOOOOOOM,1) game:GetService("Debris"):AddItem(Roomba,2) KABOOOOOOOOOOOOM.Position = Roomba.Position KABOOOOOOOOOOOOM.DestroyJointRadiusPercent = 0 end end end end end)