I am getting an error saying "Walkspeed is not a valid member of humanoid" I am trying to give the player a speedboost when they have a sword equipped. here is my code. I know 70 lines of code might be too much to look through. I can shorten it to just the walkspeed part of the code if that is better
local speedboost = 1.25
local speedboost = 1.25
local damage = 30
local swingtime = 1
local combowindow = .5
local Handle = Tool:WaitForChild("Handle")
local event = Tool:WaitForChild("RemoteEvent")
local slashsound = Handle:WaitForChild("SlashSound")
local overheadsound = Handle:WaitForChild("OverSound")
local lungesound = Handle:WaitForChild("LungeSound")
local lastclick = tick()
local combo = 0
Handle.Touched:Connect(function(hit)
if equipped and character and humanoid and humanoid.Health > 0 and hit and hit:isDecendantOf(character)then
local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
if targethumanoid and targethumanoid.Health > 0 and not hithumanoids[targethumanoid] then
hithumanoids[targethumanoid] = true
targethumanoid:TakeDamage(damage * combo)
end
end
end)
Tool.Activated:connect(function()
local clickdelta = tick() - lastclick
if clickdelta > swingtime then
lastclick = tick()
hithumanoids = {}
if clickdelta < swingtime + combowindow then
combo = (combo + 1) % 3
else
combo = 0
end
if player then
if combo then
event:FireClient(player, "RunAnimation", "SlashAnim2")
slashsound:Play()
elseif combo == 1 then
event:FireClient(player, "RunAnimation", "ThrustAnim2")
overheadsound:Play()
elseif combo == 2 then
event:FireClient(player, "RunAnimation", "OverheadAnim2")
lungesound:Play()
end
end
end
end)
Tool.Equipped:Connect(function()
equipped = true
lastclick = tick()
character = Tool.Parent
player = game.Players:GetPlayerFromCharacter(character)
humanoid = character:FindFirstChild("Humanoid")
if humanoid == nil then
humanoid.WalkSpeed = humanoid.Walkspeed + speedboost
else
character = nil
end
end)
Tool.Unequipped:Connect(function()
equipped = false
if humanoid then
humanoid.WalkSpeed = humanoid.Walkspeed / speedboost
end
character = nil
humanoid = nil
end)

1 comment
awesome, thanks for your help