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

Walkspeed script doesn't work?

Asked by 9 years ago

I'm making a script thats inside a part, so whenever someone with a humanoid touches it, the script changes their walkspeed to 65. But it doesn't work!

Script:

script.Parent.Touched:connect(function(hit)
local hum = hit.Parent.Humanoid
if hum then
    hum.Walkspeed = 30
else
print("No hum")
end
end)

Please help?

1 answer

Log in to vote
3
Answered by
hudzell 238 Moderation Voter
9 years ago
script.Parent.Touched:connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid") --Changed to :FindFirstChild("Humanoid")
    if hum ~= nil then --Added ~= nil
        hum.WalkSpeed = 30 --Capitalized the S
    else
        print("No hum")
    end
end)

Ad

Answer this question