(explanation at bottom)
Tool = script.Parent.Parent;
Handle = Tool:WaitForChild(“Handle”)
Mesh = Handle:WaitForChild(“Mesh”)
Players = game:GetService(“Players”)
Debris = game:GetService(“Debris”)
RunService = game:GetService(“RunService”)
BaseUrl = “http://www.roblox.com/asset/?id=”
Grips = {
Up = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0),
Out = CFrame.new(0, 0, -1.5, 0, -1, -0, -1, 0, -0, 0, 0, -1),
}
DamageValues = {
BaseDamage = 5,
SlashDamage = 10,
LungeDamage = 30,
}
Damage = DamageValues.BaseDamage
Sounds = {
Slash = Handle:WaitForChild(“Slash”),
Lunge = Handle:WaitForChild(“Lunge”),
Unsheath = Handle:WaitForChild(“Unsheath”),
}
LastAttack = 0
ToolEquipped = false
Tool.Enabled = true
function SwordUp()
Tool.Grip = Grips.Up
end
function SwordOut()
Tool.Grip = Grips.Out
end
function IsTeamMate(Player1, Player2)
return (Player1.TeamColor==Player2.TeamColor);
end
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new(“ObjectValue”)
Creator_Tag.Name = “creator”
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end
function UntagHumanoid(humanoid)
for i, v in pairs(humanoid:GetChildren()) do
if v:IsA(“ObjectValue”) and v.Name == “creator” then
v:Destroy()
end
end
end
function Attack()
Damage = DamageValues.SlashDamage
Sounds.Slash:Play()
local Anim = Instance.new(“StringValue”)
Anim.Name = “toolanim”
Anim.Value = “Slash”
Anim.Parent = Tool
end
function Lunge()
Damage = DamageValues.LungeDamage
Sounds.Lunge:Play()
local Anim = Instance.new(“StringValue”)
Anim.Name = “toolanim”
Anim.Value = “Lunge”
Anim.Parent = Tool
wait(0.25)
SwordOut()
wait(0.25)
wait(0.5)
SwordUp()
end
function Blow(Hit)
if not CheckIfAlive() then
return
end
local character = Hit.Parent
local humanoid = character:FindFirstChild(“Humanoid”)
if not humanoid then
return
end
local Target = Players:GetPlayerFromCharacter(character);
local Current = Player:DistanceFromCharacter(Target.Character:FindFirstChild'HumanoidRootPart'.Position)
local Connector = nil;
if Current <= 12 then
if Target.TeamColor ~= Player.TeamColor and Player.TeamColor ~= BrickColor.new'White' then
if Target then
Connector = humanoid.Died:connect(function()
Player.Character.Humanoid.Health = Player.Character.Humanoid.MaxHealth
end);
end
UntagHumanoid(humanoid);
TagHumanoid(humanoid, Player);
humanoid:TakeDamage(Damage);
wait(0.5);
Connector:disconnect();
end
end
end
function Activated()
if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
return
end
Tool.Enabled = false
local Tick = RunService.Stepped:wait()
if (Tick - LastAttack) < 0.2 then
Lunge()
else
Attack()
end
Damage = DamageValues.BaseDamage
LastAttack = Tick
Tool.Enabled = true
end
function CheckIfAlive()
return (Character and Humanoid.Health > 0)
end
function Equipped()
Character = Tool.Parent
Player = Players:GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChild(“Humanoid”)
local RootPart = Character:FindFirstChild(“HumanoidRootPart”)
if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end
function Unequipped()
ToolEquipped = false
end
SwordUp()
Handle.Touched:connect(Blow)
Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
This is the script inside the sword. My friend gave me the model he uses in his game, and it does deal damage to players on opposite teams, however, I would like it to damage all players, regardless of team. Is this possible with the current script?