local attackCooldown = 1 local attackWindup = 0.5 local attackRange = 3 local attackDamage = 20
local char = script.Parent.Parent local hum = char:WaitForChild("Humanoid") local originalWalkSpeed = hum.WalkSpeed
local canAttack = true
script.Parent.AttackRemote.Event:Connect(function(plrRoot)
if not canAttack then return end canAttack = false hun.WalkSpeed = 0.1 local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://7209529782" local playAnim = hum:LoadAnimation(anim) playAnim:Play() wait(attackWindup) local newDistance = (char.HumanoidRootPart.Position - -plrRoot.Position).magnitude if newDistance <= attackRange + 5 then if plrRoot.parent.Player.isBlocking.Value == true then attackDamage *= 0.5 end plrRoot.Parent.Humanoid:takeDamage(attackDamage) wait(attackCooldown) hum.WalkSpeen = orininalWalkSpeed canAttack = true end end)
Lua is case sensitive, so you need the 's' to be also capitalized.
hun.WalkSpeed = 0.1
Problem:
You are trying to set a value of a misspelled variable, and failed to capitalize the 'S' in hum.WalkSpeed.
Solution:
Fix the misspelled words and capitalization.
Code:
local attackCooldown = 1 local attackWindup = 0.5 local attackRange = 3 local attackDamage = 20 local char = script.Parent.Parent local hum = char:WaitForChild("Humanoid") -- the variable you defined local originalWalkSpeed = hum.WalkSpeed local canAttack = true script.Parent.AttackRemote.Event:Connect(function(plrRoot) if not canAttack then return end canAttack = false hum.WalkSpeed = 0.1 -- this was "hun.Walkspeed" local anim = Instance.new("Animation") anim.AnimationId = "rbxassetid://7209529782" local playAnim = hum:LoadAnimation(anim) playAnim:Play() wait(attackWindup) local newDistance = (char.HumanoidRootPart.Position - plrRoot.Position).magnitude if newDistance <= attackRange + 5 then if plrRoot.parent.Player.isBlocking.Value == true then attackDamage *= 0.5 end plrRoot.Parent.Humanoid:takeDamage(attackDamage) wait(attackCooldown) hum.WalkSpeed = orininalWalkSpeed -- this was "hum.Walkspeed" canAttack = true end end)