0% found this document useful (0 votes)
15 views6 pages

Grumbe Chaser - Lua

The document is a Lua script for a Roblox game that implements a sword tool with various attack functionalities, including slashing and lunging, along with damage values and animations. It also includes a feature to spawn a dummy character that follows the player and performs animations based on its health status. The script handles player interactions, weapon equipping, and damage tagging for combat mechanics.

Uploaded by

wzawadzka79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

Grumbe Chaser - Lua

The document is a Lua script for a Roblox game that implements a sword tool with various attack functionalities, including slashing and lunging, along with damage values and animations. It also includes a feature to spawn a dummy character that follows the player and performs animations based on its health status. The script handles player interactions, weapon equipping, and damage tagging for combat mechanics.

Uploaded by

wzawadzka79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

-- Q TO SPAWN

local Speed = 12

local Players = game:GetService("Players")


local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local UserInputService = game:GetService("UserInputService")

local Player = Players.LocalPlayer


local Character = Player.Character or Player.CharacterAdded:Wait()

local Sword = game:GetObjects("rbxassetid://72674416931709")[1]

local Cache = game:GetObjects("rbxassetid://96223289630255")[1]


local Cache2 = game:GetObjects("rbxassetid://103869039972033")[1]

Cache:Destroy()
Cache2:Destroy()

Sword.Parent = Player.Backpack

task.spawn(function()
local Tool = Sword
local Handle = Tool:WaitForChild("Handle")
local Humanoid = Character.Humanoid
local Torso = Character:FindFirstChild("Torso") or
Character:FindFirstChild("HumanoidRootPart")

local function Create(ty)


return function(data)
local obj = Instance.new(ty)
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
end

local BaseUrl = "rbxassetid://"

local DamageValues = {
BaseDamage = 5,
SlashDamage = 10,
LungeDamage = 30
}

local Animations = {
R15Slash = 522635514,
R15Lunge = 522638767
}

local Damage = DamageValues.BaseDamage

local Grips = {
Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
}

local Sounds = {
Slash = Handle:WaitForChild("SwordSlash"),
Lunge = Handle:WaitForChild("SwordLunge"),
Unsheath = Handle:WaitForChild("Unsheath")
}

local ToolEquipped = false

Tool.Grip = Grips.Up
Tool.Enabled = true

local function IsTeamMate(Player1, Player2)


return (Player1 and Player2 and not Player1.Neutral and not
Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

local 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

local 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

local function CheckIfAlive()


return (((Player and Player.Parent and Character and Character.Parent
and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and
Torso.Parent) and true) or false)
end

local function Blow(Hit)


if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped
then
return
end
local RightArm = Character:FindFirstChild("Right Arm") or
Character:FindFirstChild("RightHand")
if not RightArm then
return
end
local RightGrip = RightArm:FindFirstChild("RightGrip")
if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~=
Handle) then
return
end
local character = Hit.Parent
if character == Character then
return
end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health == 0 then
return
end
local player = Players:GetPlayerFromCharacter(character)
if player and (player == Player or IsTeamMate(Player, player)) then
return
end
UntagHumanoid(humanoid)
TagHumanoid(humanoid, Player)
humanoid:TakeDamage(Damage)
end

local function Attack()


Damage = DamageValues.SlashDamage
Sounds.Slash:Play()

if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Slash")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end
end

local function Lunge()


Damage = DamageValues.LungeDamage

Sounds.Lunge:Play()

if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Lunge")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end

wait(0.2)
Tool.Grip = Grips.Out
wait(0.6)
Tool.Grip = Grips.Up
Damage = DamageValues.SlashDamage
end

Tool.Enabled = true
local LastAttack = 0

local 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
LastAttack = Tick
Damage = DamageValues.BaseDamage
local SlashAnim = (Tool:FindFirstChild("R15Slash") or
Create("Animation"){
Name = "R15Slash",
AnimationId = BaseUrl .. Animations.R15Slash,
Parent = Tool
})

local LungeAnim = (Tool:FindFirstChild("R15Lunge") or


Create("Animation"){
Name = "R15Lunge",
AnimationId = BaseUrl .. Animations.R15Lunge,
Parent = Tool
})
Tool.Enabled = true
end

local function Equipped()


if not CheckIfAlive() then
return
end
ToolEquipped = true
Sounds.Unsheath:Play()
end

local function Unequipped()


Tool.Grip = Grips.Up
ToolEquipped = false
end

Tool.Activated:Connect(Activated)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)

Handle.Touched:Connect(Blow)
end)

UserInputService.InputBegan:Connect(function(input, gP)
if input.KeyCode == Enum.KeyCode.Q and not gP then
local Dummy = game:GetObjects("rbxassetid://96223289630255")[1]
local Grumbo = game:GetObjects("rbxassetid://103869039972033")[1]

Dummy.Parent = workspace
Grumbo.Parent = workspace

Dummy.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame +
Vector3.new(math.random(-15, 15), 0, math.random(-15, 15))

task.wait()

local Idle =
Grumbo.GrumbleRig.AnimationController.Animator:LoadAnimation(Grumbo.GrumbleRig.Idle
)
Idle.Looped = true
Idle:Play()

local Blink =
Grumbo.GrumbleRig.AnimationController.Animator:LoadAnimation(Grumbo.GrumbleRig.Blin
k)

local Stun =
Grumbo.GrumbleRig.AnimationController.Animator:LoadAnimation(Grumbo.GrumbleRig.Stun
)

task.spawn(function()
while Grumbo:IsDescendantOf(workspace) do
task.wait(math.random(2, 5))
Blink:Play()
end
end)

local function followPlayer()


local Direction = (Character.HumanoidRootPart.Position -
Dummy.HumanoidRootPart.Position).unit
Dummy.HumanoidRootPart.Velocity = Direction * Speed
Dummy.HumanoidRootPart.CFrame =
CFrame.new(Dummy.HumanoidRootPart.Position, Character.HumanoidRootPart.Position)
end

Dummy.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
if Dummy.Humanoid.Health <= 0 then
Stun:Play()
task.wait(1)
Dummy:Destroy()
Grumbo:Destroy()
end
end)

RunService.RenderStepped:Connect(function()
if Grumbo:IsDescendantOf(workspace) and
Dummy:IsDescendantOf(workspace) and Dummy:FindFirstChild("HumanoidRootPart") and
Dummy:FindFirstChild("Humanoid").Health > 0 then
local Distance = (Character.HumanoidRootPart.Position -
Dummy.HumanoidRootPart.Position).magnitude

if Distance <= math.huge then


followPlayer()
end
Grumbo:PivotTo(Dummy.HumanoidRootPart.CFrame)
end
end)
end
end)

You might also like