-- Services
local cas = game:GetService("ContextActionService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local chara = player.Character or player.CharacterAdded:Wait() -- Chara from Innertail?! :0 :O :o
local humanoid = chara:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local itemList = require(game.ReplicatedStorage.BaseWeaponProperties)
local ACTION_BASIC_ATTACK = "Basic Attack"
-- Things
local tool = script.Parent
local finishSwing = false
local comboCount = 1
local function handleAction(actionName, inputState, _inputObject)
if script.CooldownValue.Value == 0 then
if actionName == ACTION_BASIC_ATTACK and inputState == Enum.UserInputState.Begin then
if finishSwing == false then
script.Parent.DamageScript.StartAndEnd:FireServer()
script.Parent.ComboHandler.ComboEnd:FireServer()
print(comboCount)
local swingAnim = Instance.new("Animation")
if comboCount == 1 then
swingAnim.AnimationId = "rbxassetid://18652765616"
elseif comboCount == 2 then
swingAnim.AnimationId = "rbxassetid://18652917464"
end
local animTrack = animator:LoadAnimation(swingAnim)
animTrack:Play()
finishSwing = true
comboCount += 1
if comboCount > itemList.Data.BasicSword.comboLength then
comboCount = 1
end
task.wait(itemList.Data.BasicSword.baseAttackDuration)
if comboCount ~= 1 then
if script.Parent.ComboHandler.CountingDown.Value == true then
script.Parent.ComboHandler.ComboRefresh:FireServer()
elseif comboCount ~= 1 then
script.Parent.ComboHandler.TimerStart:FireServer()
end
end
if comboCount == 1 then
while script.CooldownValue.Value < itemList.Data.BasicSword.baseCooldown do
script.CooldownValue.TimerTick:FireServer()
wait(.1)
end
script.CooldownValue.TimerTick:FireServer()
end
finishSwing = false
script.Parent.DamageScript.StartAndEnd:FireServer()
end
end
end
end
local function resetCombo()
comboCount = 1
end
tool.Equipped:Connect(function()
cas:BindAction(ACTION_BASIC_ATTACK, handleAction, false, Enum.UserInputType.MouseButton1)
end)
tool.Unequipped:Connect(function()
cas:UnbindAction(ACTION_BASIC_ATTACK)
end)
script.ResetCombo.OnClientEvent:Connect(resetCombo)
It makes the damage work. Not much has changed other than that.
DamageScript:
local StartEnd = script.StartAndEnd
local swingStatus = false
local hitbox = script.Parent.Hitbox
local statList = require(game.ReplicatedStorage.BaseWeaponProperties)
local beenHit = false
local function swingStatusChange()
if swingStatus == false then
swingStatus = true
else
swingStatus = false
beenHit = false
end
end
StartEnd.OnServerEvent:Connect(swingStatusChange)
hitbox.Touched:Connect(function(otherPart)
if swingStatus == true then
if beenHit == true then return end
beenHit = true
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health -= statList.Data.BasicSword.baseDamage
end
end
end)
When it touches something that has a humanoid while you’re swinging, it damages them. It automatically has it so it doesn’t damage you when you use it, so that’s convenient.
Plans:
Add knockback and implement a system for missing a finisher.
Disable collisions with other players and NPCs (help needed).
Got the movement to stop while you’re swinging. However, you’ll be locked in place if you start a swing and unequip your weapon during it. That’s basically all for day 4 and day 5.
tip: if you insert a free model a great way to see if there are viruses to check if they’re properly vaccinated. if there aren’t any parts crammed with suspicious lines of code called ‘vaccine’ then its definitely a virus
School starts soon, and that means I’ll have a lot less time to get on Studio and code every day, so I’ll have to update the devlog less often. Did I say that I’d update it daily? Yes. Do I think it’ll be less boring if I only update it when I finish something? Also yes.
I expect to work on the game for an average of two hours on every week day (except for every other Friday night and every third Wednesday, I have other things to do on those days), and work on it for an average of six hours a day on weekends. I’ll update the devlog when I either finish something or I need help.
Also, don’t judge graphics or game mechanics yet. If you do, I won’t take any of your developing advice seriously because you’re showing that you know nothing about the pipeline of making games.
It’s been a while, but I’m happy to say that I’ve got motivation again, and I’m getting close to finishing my (m1) weapon system. I only need to implement knockback, fix bugs, and add things that make the combat interesting and unique.
Here’s a demonstration of the sword with some known bugs.
Bugs:
Built in shiftlock can overlap with forced shiftlock, causing extra offset (I can solve this issue myself).
You go flying when you jump and attack or when you attack and unequip quickly (I could make the jumping attack a feature, but I need to nerf it a lot or disable it entirely).
Binds to RenderStep twice if you unequip the weapon quickly and attack again, causing an error.
For reference, this is the new code for the Trigger script:
local cas = game:GetService("ContextActionService")
local Players = game:GetService("Players")
local uis = game:GetService("UserInputService")
local Runs = game:GetService("RunService")
local player = Players.LocalPlayer
local chara = player.Character or player.CharacterAdded:Wait() -- Chara from Innertail?! :0 :O :o
local humanoid = chara:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local root = chara.HumanoidRootPart
local noTurn = false
local weaponData = require(game.ReplicatedStorage.BaseWeaponProperties).Data.BasicSword
local ACTION_BASIC_ATTACK = "Basic Attack"
local camera = workspace.CurrentCamera
-- Things
local tool = script.Parent
local finishSwing = false
local torsoRotating = false
local comboCount = 1
local function handleAction(actionName, inputState, _inputObject)
if script.CooldownValue.Value == 0 then
if actionName == ACTION_BASIC_ATTACK and inputState == Enum.UserInputState.Begin then
if finishSwing == false then
Runs:UnbindFromRenderStep("ShiftLock")
script.Parent.SwingScript.Start:FireServer()
script.Parent.ComboHandler.ComboEnd:FireServer()
print(comboCount)
local swingAnim = Instance.new("Animation")
if comboCount == 1 then
swingAnim.AnimationId = "rbxassetid://18652765616"
elseif comboCount == 2 then
swingAnim.AnimationId = "rbxassetid://18652917464"
end
local animTrack = animator:LoadAnimation(swingAnim)
animTrack:Play()
finishSwing = true
comboCount += 1
if comboCount > weaponData.comboLength then
comboCount = 1
end
wait(weaponData.baseAttackDuration)
humanoid.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
humanoid.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
Runs:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
end)
if comboCount ~= 1 then
if script.Parent.ComboHandler.CountingDown.Value == true then
script.Parent.ComboHandler.ComboRefresh:FireServer()
elseif comboCount ~= 1 then
script.Parent.ComboHandler.TimerStart:FireServer()
end
end
if comboCount == 1 then
script.Parent.SwingScript.StopMoving:FireServer()
script.Parent.SwingScript.SlowDown:FireServer()
while script.CooldownValue.Value < weaponData.baseCooldown do
script.CooldownValue.TimerTick:FireServer()
wait(.1)
end
script.CooldownValue.TimerTick:FireServer()
script.Parent.SwingScript.SlowDownEnd:FireServer()
end
finishSwing = false
script.Parent.SwingScript.End:FireServer()
end
end
end
end
local function resetCombo()
comboCount = 1
end
function shiftLock(active) --Toggle shift.lock function
if active then
humanoid.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
humanoid.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
Runs:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
end)
else
humanoid.AutoRotate = true --Let the humanoid handle the camera rotations again.
humanoid.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
Runs:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
uis.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
end
end
tool.Equipped:Connect(function()
shiftLock(true)
cas:BindAction(ACTION_BASIC_ATTACK, handleAction, false, Enum.UserInputType.MouseButton1)
end)
tool.Unequipped:Connect(function()
shiftLock(false)
cas:UnbindAction(ACTION_BASIC_ATTACK)
end)
script.ResetCombo.OnClientEvent:Connect(resetCombo)
Managed to fix all of the bugs on my own, here’s what the sword is like now.
I managed to fix the flying that happens by replacing the VectorForce that I was using to make it work with a LinearVelocity, which makes the distance much more consistent.
I fixed the shiftlock by making a separate script with two different variables that meant a different reason for shiftlock. One was for automatic shiftlock on tools, and the other was for manual shiftlock by pressing Ctrl/Shift/Alt (I haven’t decided yet). You can’t bind the shiftlock more than once with that script, which means that the issue of extra offset and binding to RenderStep twice is now fixed.
I also got rid of the ability to jump while you’re in endlag and reduced the default JumpPower from 50 to 35 to make the height of your jumping more reasonable.
Now I can actually focus on the rest of the weapon mechanics.