Would it be possible to create a seperate script for this that runs on the client or server?
Also this is my sword script if its possible to modify it
local config = {
-- BASIC SETTINGS
antiTeamkill = true;
float = "none"; -- can be "none", "mid", or "full"
slashDamage = 10; -- default 10
lungeDamage = 40; -- default 50
-- CHEAT SETTINGS
pgsFix = true; -- lowers damage for the new PGS physics solver
antiSwordChange = true; -- if true, prevents changing sword size, properties, etc
antiTie = false; -- prevents killing once someone has died
-- ADVANCED SETTINGS
floatMatchesAnimation = false; -- if true, sword will be full float on OA, and no float on NA
floatToolName = false; -- if true, the sword icon will be replaced with the type of float
floatToolTip = true; -- if true, mousing over the sword displays the type of float
mouseIcon = false; -- if true, displays the classic circle sword icon
exposeConfig = true; -- creates a "config" folder in this script for in-game setting changes
}
--[[NEEDS DOING]]
-- DO NOT EDIT BELOW THIS LINE
function new(typeOf, props)
local obj = Instance.new(typeOf)
for k, v in pairs(props) do
obj[k] = v
end
return obj
end
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")
local tool = script.Parent
local sword = tool.Handle
local acceptable = {"Head"; "Left Arm"; "Left Leg"; "Right Arm"; "Right Leg"; "Torso"}
local currDamage = config.slashDamage
local lastAttack = 0
local debounce
local floatChange
local sounds = {
slash = new("Sound", {
Name = "Slash";
Volume = .7;
SoundId = "rbxasset://sounds\\swordslash.wav";
Parent = sword;
});
lunge = new("Sound", {
Name = "Lunge";
Volume = .6;
SoundId = "rbxasset://sounds\\swordlunge.wav";
Parent = sword;
});
unsheath = new("Sound", {
Name = "Unsheath";
Volume = 1;
SoundId = "rbxasset://sounds\\unsheath.wav";
Parent = sword;
});
}
function getFloatName()
return (config.float == "full" and "Full") or (config.float == "mid" and "Mid") or "No"
end
function canDamage(p1, p2)
return config.antiTeamkill ~= true or p1.TeamColor ~= p2.TeamColor or p1.Neutral or p2.Neutral
end
function matches(name)
for _, v in ipairs(acceptable) do
if name == v then return true end
end
return false
end
function tagHumanoid(hum, player)
local creator = Instance.new("ObjectValue")
creator.Name = "creator"
creator.Value = player
creator.Parent = hum
Debris:AddItem(creator, 1)
end
function damage(hum, damage, myPlayer)
if config.pgsFix and debounce == true then return end
debounce = true
tagHumanoid(hum, myPlayer)
hum:TakeDamage(damage)
if config.pgsFix then
wait()
debounce = false
end
end
function blow(hit)
if hit.Parent == nil then return end
if matches(hit.Name) then
local myChar = tool.Parent
local myPlayer = game.Players:GetPlayerFromCharacter(myChar)
local myHum = myChar:FindFirstChild("Humanoid")
local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
local hitHum = hit.Parent:FindFirstChild("Humanoid")
if hitHum and myHum and hitHum ~= myHum and (not config.antiTie or myHum.Health > 0) then
local arm = myChar:FindFirstChild("Right Arm")
if arm then
local joint = arm:FindFirstChild("RightGrip")
if joint and (joint.Part0 == sword or joint.Part1 == sword) then
if hitPlayer then -- real player
if canDamage(myPlayer, hitPlayer) then
damage(hitHum, currDamage, myPlayer)
end
else -- NPCs
damage(hitHum, currDamage, myPlayer)
end
end
end
end
end
end
function attack()
currDamage = config.slashDamage
sounds.slash:Play()
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = tool
end
function lunge()
currDamage = config.lungeDamage
sounds.lunge:Play()
local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Lunge"
anim.Parent = tool
if config.float == "mid" or config.float == "full" then
local root = tool.Parent and tool.Parent:FindFirstChild("HumanoidRootPart")
if root then
local floatVal = config.float == "full" and 2900 or 2328
local force = Instance.new("BodyVelocity")
force.Velocity = Vector3.new(0, 10, 0)
force.MaxForce = Vector3.new(0, floatVal, 0)
force.Parent = root
Debris:AddItem(force, .5)
end
end
wait(0.3)
swordOut()
wait(0.6)
swordUp()
currDamage = config.slashDamage
end
function swordUp()
tool.GripForward = Vector3.new(-1,0,0)
tool.GripRight = Vector3.new(0,1,0)
tool.GripUp = Vector3.new(0,0,1)
end
function swordOut()
tool.GripForward = Vector3.new(0,0,1)
tool.GripRight = Vector3.new(0,-1,0)
tool.GripUp = Vector3.new(-1,0,0)
end
function floatChanged()
tool.ToolTip = config.floatToolTip and getFloatName() .. " Float" or ""
if config.floatToolName == true then
tool.TextureId = ""
tool.Name = getFloatName() .. "Float"
end
end
function determineAnimation(char)
local isOA = true
for _, c in ipairs(char:GetChildren()) do
if c:IsA("LocalScript") and c:FindFirstChild("walk") and c:FindFirstChild("sit") then
isOA = false
end
end
return isOA and "OA" or "NA"
end
tool.Activated:connect(function()
--print"activated"
local char = tool.Parent
local hum = char:FindFirstChild("Humanoid")
if not tool.Enabled then return end
if not hum then return end
tool.Enabled = false
local t = RunService.Stepped:Wait()
if t - lastAttack < .2 then lunge() else attack() end
lastAttack = t
tool.Enabled = true
end)
tool.Equipped:connect(function()
sounds.unsheath:Play()
if (not floatChange or floatChange.Value == "") and config.floatMatchesAnimation then
local char = tool.Parent
if char and char:IsDescendantOf(workspace) then
local anim = determineAnimation(char)
config.float = anim == "OA" and "full" or "none"
floatChanged()
end
end
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
sword:SetNetworkOwner(player)
end)
-- START UP
if config.exposeConfig and tool:FindFirstChild("SwordScript") then
local vFolder = new("Folder", {Name = "config"})
floatChange = new("StringValue", {Name = "float"; Value = ""; Parent = vFolder})
floatChange:GetPropertyChangedSignal("Value"):connect(function()
config.float = floatChange.Value
floatChanged()
end)
vFolder.Parent = tool.SwordScript
end
local cFolder = new("Folder", {Name = "config"})
new("BoolValue", {Name = "icon"; Value = config.mouseIcon == true; Parent = cFolder})
new("BoolValue", {Name = "change"; Value = config.antiSwordChange == true; Parent = cFolder})
floatChanged()
cFolder.Parent = tool.client
tool.Enabled = true
sword.Touched:connect(blow) -- toggle damaging