Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CLIENT LOCAL SCRIPT
- local tool = script.Parent
- local uis = game:GetService("UserInputService")
- local rs = game:GetService("RunService")
- local plr = game.Players.LocalPlayer
- local ShiftLock = require(plr:WaitForChild("PlayerScripts"):WaitForChild("CustomShiftLock"):WaitForChild("SmoothShiftLock"))
- local char = plr.Character
- local hum = char:WaitForChild("Humanoid")
- local equipped = false
- local remote = game.ReplicatedStorage.Remotes.GladiusRemote
- local swordRemote = game.ReplicatedStorage.Remotes.GladiusSwordRemote
- local shieldRotationRemote = game.ReplicatedStorage.Remotes.RotationRemote
- local attributeRemote = game.ReplicatedStorage.Remotes.AttributeRemote
- local debounce = false
- local doubleDebounce = false
- local thurstUp = false
- local isCharging = false
- local isCharged = false
- local animEnded = true
- local lastAttackPos = nil
- local coolDownTime = 1
- local connections = {}
- local idleTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusPose)
- local blockUpTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusBlock)
- local blockLowTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusBlockLow)
- local thrustLowTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustLow)
- local thrustUpTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustUp)
- local thrustLowHitTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustLowHit)
- local thrustUpHitTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustUpHit)
- thrustUpHitTrack.Stopped:Connect(function()
- animEnded = true
- end)
- thrustLowHitTrack.Stopped:Connect(function()
- animEnded = true
- end)
- local shieldWeld: Weld = plr.Character:WaitForChild("Shield"):WaitForChild("Meshes/Shield G"):WaitForChild("ShieldWeldTemplate")
- local gui = script.Parent.WeaponGui:Clone()
- gui.Parent = plr.PlayerGui
- local function EndCooldown()
- debounce = false
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
- lastAttackPos = nil
- end
- local function EndDoubleCooldown()
- doubleDebounce = false
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
- end
- local function RemoveConnections()
- for i,v in pairs(connections) do
- v:Disconnect()
- end
- table.clear(connections)
- end
- local function UpOrDown()
- return workspace.CurrentCamera.CFrame.LookVector.Y
- end
- rs.Heartbeat:Connect(function(deltaTime)
- thurstUp = UpOrDown() >= -0.3
- if thurstUp then
- gui.Crosshair.Frame.TopBlock.ImageTransparency = 0
- gui.Crosshair.Frame.BottomBlock.ImageTransparency = 1
- else
- gui.Crosshair.Frame.TopBlock.ImageTransparency = 1
- gui.Crosshair.Frame.BottomBlock.ImageTransparency = 0
- end
- end)
- tool.Equipped:Connect(function()
- equipped = true
- thurstUp = true
- gui.Enabled = true
- swordRemote:FireServer(plr.Character:WaitForChild("Sword"):WaitForChild("Meshes/Espada Um a Tres_SM_Sword_Gladius_02_LOD0"), 1)
- ShiftLock:ToggleShiftLock(true)
- uis.MouseIconEnabled = false
- idleTrack:Play()
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- gui.Enabled = false
- swordRemote:FireServer(plr.Character:WaitForChild("Sword"):WaitForChild("Meshes/Espada Um a Tres_SM_Sword_Gladius_02_LOD0"), 0)
- ShiftLock:ToggleShiftLock(false)
- uis.MouseIconEnabled = true
- idleTrack:Stop()
- blockUpTrack:Stop()
- blockLowTrack:Stop()
- end)
- uis.InputBegan:Connect(function(input, process)
- if process then return end
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if not equipped then return end
- if debounce then return end
- if plr.Character:GetAttribute("State") == "Default" then
- if not isCharging then
- isCharging = true
- if thurstUp then
- if lastAttackPos == "Up" then
- isCharging = false
- debounce = true
- task.delay(1, EndCooldown)
- return
- end
- attributeRemote:FireServer("State", "Attacking")
- attributeRemote:FireServer("AttackPos", "Up")
- lastAttackPos = "Up"
- thrustUpTrack:Play()
- thrustUpTrack:AdjustSpeed(0.8)
- local connect = thrustUpTrack:GetMarkerReachedSignal("Stop"):Connect(function()
- thrustUpTrack:AdjustSpeed(0)
- isCharged = true
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
- doubleDebounce = true
- task.delay(coolDownTime, EndDoubleCooldown)
- end)
- table.insert(connections, connect)
- elseif not thurstUp then
- if lastAttackPos == "Down" then
- isCharging = false
- debounce = true
- task.delay(1, EndCooldown)
- return
- end
- attributeRemote:FireServer("State", "Attacking")
- attributeRemote:FireServer("AttackPos", "Down")
- lastAttackPos = "Down"
- thrustLowTrack:Play()
- thrustLowTrack:AdjustSpeed(0.8)
- local connect = thrustLowTrack:GetMarkerReachedSignal("Stop"):Connect(function()
- thrustLowTrack:AdjustSpeed(0)
- isCharged = true
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
- doubleDebounce = true
- task.delay(coolDownTime, EndDoubleCooldown)
- end)
- table.insert(connections, connect)
- end
- end
- end
- end
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- if not equipped then return end
- if not animEnded then return end
- if isCharging then
- isCharging = false
- isCharged = false
- attributeRemote:FireServer("State", "Default")
- thrustUpTrack:Stop()
- thrustLowTrack:Stop()
- end
- if thurstUp then
- attributeRemote:FireServer("State", "Blocking")
- attributeRemote:FireServer("BlockPos", "Up")
- blockUpTrack:Play()
- shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
- shieldRotationRemote:FireServer(shieldWeld, "Shield", "Modified")
- elseif not thurstUp then
- attributeRemote:FireServer("State", "Blocking")
- attributeRemote:FireServer("BlockPos", "Down")
- shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
- shieldRotationRemote:FireServer(shieldWeld, "Shield", "Modified")
- blockLowTrack:Play()
- end
- end
- end)
- uis.InputEnded:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton2 then
- shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
- shieldRotationRemote:FireServer(shieldWeld, "Shield", "Original")
- blockUpTrack:Stop()
- blockLowTrack:Stop()
- if plr.Character:GetAttribute("State") == "Blocking" then
- attributeRemote:FireServer("State", "Default")
- end
- end
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- if not isCharging then return end
- if debounce then return end
- if not isCharged then
- debounce = true
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
- task.wait(0.27)
- task.delay(coolDownTime, EndCooldown)
- end
- if doubleDebounce then
- debounce = true
- gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
- task.delay(coolDownTime, EndCooldown)
- end
- RemoveConnections()
- doubleDebounce = true
- isCharged = false
- isCharging = false
- thrustUpTrack:Stop()
- thrustLowTrack:Stop()
- local sound = game.SoundService.SwordSwing:Clone()
- sound.Parent = char
- sound:Destroy()
- if plr.Character:GetAttribute("State") == "Attacking" then
- if plr.Character:GetAttribute("AttackPos") == "Up" then
- thrustUpHitTrack:Play()
- thrustUpHitTrack:AdjustSpeed(0.5)
- animEnded = false
- local connect = thrustUpHitTrack.Stopped:Connect(function()
- task.wait(0.2)
- end)
- table.insert(connections, connect)
- remote:FireServer("Up", tool.Main)
- task.wait(0.03)
- elseif plr.Character:GetAttribute("AttackPos") == "Down" then
- thrustLowHitTrack:Play()
- thrustLowHitTrack:AdjustSpeed(0.5)
- animEnded = false
- remote:FireServer("Down", tool.Main)
- end
- end
- if plr.Character:GetAttribute("State") == "Attacking" then
- attributeRemote:FireServer("State", "Default")
- end
- end
- end)
- -- SERVER SCRIPT
- local remote = game.ReplicatedStorage.Remotes.GladiusRemote
- local swordRemote = game.ReplicatedStorage.Remotes.GladiusSwordRemote
- local ReplicatedStorage = game.ReplicatedStorage
- local RaycastHitbox = require(ReplicatedStorage.Modules.RaycastHitboxV4)
- swordRemote.OnServerEvent:Connect(function(plr, item, transparency)
- item.Transparency = transparency
- end)
- remote.OnServerEvent:Connect(function(plr, state, sword)
- if state == "Up" then
- local char = plr.Character
- local humrp = char.HumanoidRootPart
- local hitbox = RaycastHitbox.new(sword)
- hitbox.Visualizer = true
- hitbox.OnHit:Connect(function(hit, hum)
- if hum.Parent ~= char then
- if hum.Parent:GetAttribute("State") == "Blocking" then
- if hum.Parent:GetAttribute("BlockPos") == "Up" then
- local sound = game.SoundService.ShieldBlock:Clone()
- sound.Parent = hit
- sound:Destroy()
- return
- end
- end
- local sound = game.SoundService.SwordHit:Clone()
- sound.Parent = hit
- sound:Destroy()
- hum:TakeDamage(30)
- end
- end)
- hitbox:HitStart()
- task.wait(0.4)
- hitbox:HitStop()
- elseif state == "Down" then
- local char = plr.Character
- local humrp = char.HumanoidRootPart
- local hitbox = RaycastHitbox.new(sword)
- hitbox.Visualizer = true
- hitbox.OnHit:Connect(function(hit, hum)
- if hum.Parent ~= char then
- if hum.Parent:GetAttribute("State") == "Blocking" then
- if hum.Parent:GetAttribute("BlockPos") == "Down" then
- local sound = game.SoundService.ShieldBlock:Clone()
- sound.Parent = hit
- sound:Destroy()
- return
- end
- end
- local sound = game.SoundService.SwordHit:Clone()
- sound.Parent = hit
- sound:Destroy()
- hum:TakeDamage(30)
- end
- end)
- hitbox:HitStart()
- task.wait(0.4)
- hitbox:HitStop()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement