script.Parent.Touched:connect(function()
script.Parent:FindFirstChild("Humanoid")
local h = script.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = 50
script.Parent.TouchEnded:connect(function()
script.Parent:FindFirstChild("Humanoid")
local h = script.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = 16
end)
end)
--]]This script is supposed to make the player's walkspeed 50 when they touched it, and when they got off the brick, it was supposed to reset the walkspeed back to 16, what's wrong here?
Output says
Workspace.Part.Script:4: attempt to index local 'h' (a nil value)
OR -- I already made this script, waay before the other guy used it in comments
script.Parent.Touched:connect(function()
script.Parent:FindFirstChild("Humanoid")
local h = script.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = 50
end)
script.Parent.TouchEnded:connect(function()
script.Parent:FindFirstChild("Humanoid")
local h = script.Parent:FindFirstChild("Humanoid")
h.WalkSpeed = 16
end)
Output says
17:31:48.911 - Workspace.Part.Script:4: attempt to index local 'h' (a nil value)
-- and
17:31:51.887 - Workspace.Part.Script:10: attempt to index local 'h' (a nil value)

1 comment
WHY DID SOMEONE DOWNVOTE ME?! What did I DO?!