I'm working on a game where I need a part that when the player looks at it, it reduces their walkspeed. I have next to no experience in LUA and what experience I do have is copy-pasting snippets of code into other code and crossing my fingers that it works. For this I've done a lot of research and work and I still can't figure it out. What I've been doing is taking the example code from the ROBLOX developer website:
script.Parent.ClickDetector.MouseHoverLeave:Connect(function(Player)
print("Oh my... " .. Player.Name .. " left the confines of my parent")
end)
And in place of line 2, I've just been copy-pasting vague "change the player's walkspeed" arguments and I don't understand. I know that there is some kind of "Player Who Hovered" argument, but there's been little in-depth documentation of click detectors that I can find, and I'm not experienced enough in LUA to get it. If you could help me, I would be a very happy boy.
For reference, a snippet of walkspeed code that I have been trying:
script.Parent.Touched:connect(function(p)
if p.Parent:FindFirstChild("Humanoid") then
p.Parent.Humanoid.WalkSpeed = 40
wait(10)
p.Parent.Humanoid.WalkSpeed = 16
And of course, I've tried changing pieces of the code to work with click detector inputs, but this is my first day trying to do this kind of stuff.

5 comments
The first Parameter is the Player object. Try:Player.Character:FindFirstChildOfClass("Humanoid") instead
Thank you, second person so much. I've been working on this for two hours. I love you. Thank you, so much.
@evil29 @Despayr OMG im so sorry, just realized I did that, updated the post
It's okay. Lol. Thank you both, I was going insane and now I am insanely pleased with this.
@evil29 np :D make sure to accept the answer if you found it helpful!