Hello. In this script, I have included the following
local localplr = game.Players.LocalPlayer
local char = localplr.Character
local hum = char:FindFirstChild("Humanoid")
and got this error
15:21:04.792 - Players.Gmorcad12345.PlayerScripts.{NEW}WildPetEncounter:45: attempt to index nil with 'FindFirstChild'
I tried the same script but changed to WaitForChild and got the same error, just the 'findfirstchild' replaced with 'waitforchild'
how do i fix this problem? every character will have a humanoid so I don't see why this error occured. script is in a local script parented to starter player scripts
thx for ur time!!
[[EDIT]]
So at the bottom of the script, i had a Touched function. when i wrote
localplr.Character.Humanoid.WalkSpeed = 0
--in the touched function
no error occured.
(btw i commented out the line which caused an error)(line 3 of the previous script)
what could be the cause of the previous error then? im a 100% sure i spelt everything correctly
again, thanks for your time

4 comments
replace "-" on line 3 with "="
oops, that was a typo. in the actual script i actually typed it correctly and it still doesnt work.
Using the touched event on the StarterPlayerScripts is totally unnecessary. Just use a Server Script and use the touched event. Look at my answer below for more details.
see my answer