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

What is wrong with this Touched Script? [closed]

Asked by 9 years ago
script.Parent.Touched(function(part)
    local h = part.Parent.Humanoid
    if h ~= nil then
        h.WalkSpeed = 45
    end
end)

I think I just did a careless mistake. But nothing is showing up in the Output.

0
Please don't edit your titles to say "[Closed]" in them. When they actually get locked that's done automatically BlueTaslem 18071 — 9y

Locked by Redbullusa, Perci1, and BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
9 years ago

You missed the calling the connect method on the Touched event:

script.Parent.Touched:connect(function(part)
    local h = part.Parent:FindFirstChild("Humanoid") --also use FindFirstChild
    if h then --"if h" is the same as "if h ~= nil"
        h.WalkSpeed = 45
    end
end)
0
Wow I feel stupid, especially since I made the same mistake yesterday... EzraNehemiah_TF2 3552 — 9y
Ad