Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is Walkspeed not a valid memeber of humanoid?

Asked by 4 years ago

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 answer

Log in to vote
1
Answered by
ScuffedAI 435 Moderation Voter
4 years ago
Edited 4 years ago

It's because of a simple syntax error that you made. On line 64 and 73 when you tried to get the WalkSpeed, you forgot to capitalize "speed".

-- line 64
humanoid.WalkSpeed = humanoid.WalkSpeed + speedboost 

-- line 73
humanoid.WalkSpeed = humanoid.WalkSpeed / speedboost 

To make it easier for us to help you out, make sure to also include on which line the error happened next time.

0
awesome, thanks for your help Skinnygrowler 6 — 4y
Ad

Answer this question