Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------
- -------------------- Variables
- local tool = script.Parent.Parent
- local player = tool.Parent.Parent
- local character = player.Character or player.CharacterAdded:Wait()
- local remoteEvent = tool:WaitForChild("remote_event")
- --------------------
- -------------------- Functions
- function HasWeapon(humanoid)
- local descendants = humanoid.Parent:GetDescendants()
- for _, v in pairs(descendants) do
- if v:IsA("Tool") then
- if v:FindFirstChild("blade") then
- return v
- end
- end
- end
- return nil
- end
- --------------------
- -------------------- Weapon Actions
- remoteEvent.OnServerEvent:Connect(function(player, func, value)
- ----------
- ---------- Block
- if func == "Block" then
- tool.Status.blocking.Value = value
- return
- end
- ----------
- ---------- Attack
- if func == "Attack" then
- local humanoid = value
- local weapon = HasWeapon(humanoid)
- if weapon ~= nil then
- print("Has weapon out")
- if weapon.Status.blocking.Value == false then
- humanoid:TakeDamage(10)
- else
- print("blocking")
- end
- return
- end
- humanoid:TakeDamage(10)
- return
- end
- ----------
- ---------- Stun
- if func == "Stun" then
- tool.Status.stunning.Value = value
- return
- end
- ----------
- ----------
- error("Function: '" .. func .. "' not found.") -- Called function was not found
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement