Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ServerScript "FightingSystem"
- script.WeaponEvents.Parent = game:GetService("ReplicatedStorage")
- script.SwingWeapon.Parent = game:GetService("StarterPlayer").StarterPlayerScripts
- local CF = script.Armor
- game:GetService("Players").PlayerAdded:Connect(function(Player)
- Player.CharacterAdded:Connect(function(Character)
- WeldClothes(Character, CF.ShoulderPad)
- WeldClothes(Character, CF.ShoulderPad, {BodyPart = "RightUpperArm"})
- WeldClothes(Character, CF.ChestStrap)
- WeldClothes(Character, CF.Glove)
- WeldClothes(Character, CF.Glove, {BodyPart = "LeftHand", AngleOffset = Vector3.new(0, 180, 0)})
- WeldClothes(Character, CF.Belt)
- WeldClothes(Character, CF.Boot)
- WeldClothes(Character, CF.Boot, {BodyPart = "LeftFoot"})
- WeldClothes(Character, CF.UpperLegGuard)
- WeldClothes(Character, CF.UpperLegGuard, {BodyPart = "RightUpperLeg", PositionOffset = Vector3.new(0.02, 0.03, -0.01)})
- WeldClothes(Character, CF.LowerLegGuard)
- WeldClothes(Character, CF.LowerLegGuard, {BodyPart = "RightLowerLeg", PositionOffset = Vector3.new(0.02, -0.07, -0.01)})
- WeldClothes(Character, CF.ChestPlate)
- WeldClothes(Character, CF.LowerArmGuard)
- WeldClothes(Character, CF.LowerArmGuard, {BodyPart = "RightLowerArm", AngleOffset = Vector3.new(0, -90, 0), PositionOffset = Vector3.new(0.02, 0.06, 0)})
- WeldClothes(Character, CF.Helmet)
- WeldClothes(Character, CF.Staff) -- Change to CF.Sword for a sword instead of a staff.
- WeldClothes(Character, CF.Shield)
- end)
- end)
- function WeldClothes(Character, Clothes, CustomProperties)
- if not Character then return end
- if not Clothes then return end
- if not Clothes:FindFirstChild("BodyPart") then return end
- if not Clothes:FindFirstChild("PositionOffset") then return end
- if not Clothes:FindFirstChild("AngleOffset") then return end
- if not Character:FindFirstChild(Clothes.BodyPart.Value) then return end
- local Clothes = Clothes:Clone()
- local Weld = Instance.new("Weld")
- if CustomProperties then
- if CustomProperties.BodyPart then
- Clothes.BodyPart.Value = CustomProperties.BodyPart
- end
- if CustomProperties.PositionOffset then
- Clothes.PositionOffset.Value = CustomProperties.PositionOffset
- end
- if CustomProperties.AngleOffset then
- Clothes.AngleOffset.Value = CustomProperties.AngleOffset
- end
- end
- Weld.Part0 = Character:WaitForChild(Clothes.BodyPart.Value)
- Weld.Part1 = Clothes
- Weld.C0 = CFrame.new(Clothes.PositionOffset.Value) * CFrame.Angles(math.rad(Clothes.AngleOffset.Value.X), math.rad(Clothes.AngleOffset.Value.Y), math.rad(Clothes.AngleOffset.Value.Z))
- Weld.Parent = Clothes
- Clothes.Parent = Character:FindFirstChild(Clothes.BodyPart.Value)
- end
- local PlayerData = Instance.new("Folder")
- PlayerData.Name = "PlayerData"
- PlayerData.Parent = script
- game:GetService("ReplicatedStorage").WeaponEvents.Swing.OnServerEvent:Connect(function(Player, Weapon, Time)
- local Val = PlayerData:FindFirstChild(Player.Name)
- if not Val then
- Val = Instance.new("BoolValue")
- Val.Name = Player.Name
- Val.Parent = PlayerData
- end
- if Val.Value then
- Val.Value = false
- Player.Character.Humanoid.WalkSpeed = 16
- game:GetService("ReplicatedStorage").WeaponEvents.Shield:FireClient(Player)
- end
- local HitAlready = {}
- local Hitting = Weapon:FindFirstChild("Blade").Touched:Connect(function(Hit)
- if Hit.Parent:FindFirstChild("Humanoid") then
- local AlreadyHit = false
- for i, v in pairs(HitAlready) do
- if v == Hit.Parent then
- AlreadyHit = true
- break
- end
- end
- if not AlreadyHit then
- if Hit.Parent ~= Player.Character then
- local Attacker = Player.Character
- local Victim = Hit.Parent
- local Damage = Weapon.Damage.Value
- if PlayerData:FindFirstChild(Victim.Name) then
- if PlayerData:FindFirstChild(Victim.Name).Value then
- Damage = Damage * 0.1
- end
- end
- HitAlready[#HitAlready + 1] = Victim
- Victim.Humanoid.Health = Victim.Humanoid.Health - Damage
- end
- end
- end
- end)
- Weapon.Blade.Trail.Enabled = true
- wait(Time)
- Weapon.Blade.Trail.Enabled = false
- Hitting:Disconnect()
- end)
- game:GetService("ReplicatedStorage").WeaponEvents.Shield.OnServerEvent:Connect(function(Player, Value)
- local Val = PlayerData:FindFirstChild(Player.Name)
- if not Val then
- Val = Instance.new("BoolValue")
- Val.Name = Player.Name
- Val.Parent = PlayerData
- end
- Val.Value = Value
- if Value then
- Player.Character.Humanoid.WalkSpeed = 10
- else
- Player.Character.Humanoid.WalkSpeed = 16
- end
- end)
- -- LocalScript "SwingWeapon"
- local Player = game:GetService("Players").LocalPlayer
- local Mouse = Player:GetMouse()
- local SwingEvent = game:GetService("ReplicatedStorage"):WaitForChild("WeaponEvents").Swing
- local ShieldEvent = game:GetService("ReplicatedStorage"):WaitForChild("WeaponEvents").Shield
- local Time = 0.4
- local ShieldTime = 0.5
- local SlashOne = true
- local Debounce = false
- local SlashOneAnimation = "rbxassetid://03502981317"
- local SlashTwoAnimation = "rbxassetid://3503074713"
- local ShieldAnimation = "rbxassetid://3503279598"
- Mouse.Button1Down:Connect(function()
- if not Player.Character:FindFirstChild("HumanoidRootPart") then return end
- if Debounce then return end
- Debounce = true
- local Animation = Instance.new("Animation")
- if SlashOne then
- SlashOne = false
- Animation.AnimationId = SlashOneAnimation
- else
- SlashOne = true
- Animation.AnimationId = SlashTwoAnimation
- end
- local Weapon = Player.Character.RightHand:FindFirstChildOfClass("Part") or Player.Character.RightHand:FindFirstChildOfClass("UnionOperation")
- SwingEvent:FireServer(Weapon, Time)
- local Humanoid = Player.Character:FindFirstChild("Humanoid")
- local Anim = Humanoid:LoadAnimation(Animation)
- Anim:Play()
- wait(Time)
- Debounce = false
- end)
- local Anim
- Mouse.Button2Down:Connect(function()
- ShieldEvent:FireServer(true)
- local Humanoid = Player.Character:FindFirstChild("Humanoid")
- local Animation = Instance.new("Animation")
- Animation.AnimationId = ShieldAnimation
- Anim = Humanoid:LoadAnimation(Animation)
- Anim:Play()
- wait(ShieldTime - (ShieldTime*0.01))
- if Anim then
- Anim:AdjustSpeed(0)
- end
- end)
- Mouse.Button2Up:Connect(function()
- ShieldEvent:FireServer(false)
- if Anim then
- Anim:Stop()
- end
- Anim = nil
- end)
- ShieldEvent.OnClientEvent:Connect(function()
- if Anim then
- Anim:Stop()
- end
- Anim = nil
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement