How do I fix this? I'm pretty new to scripting and I'm trying to change the walkspeed of the player who touches the part. I've been trying to look for a way to see what refers to any player so that I can do things like change the walkspeed of anyone who touches the part which is what I try to do below. This is what I used to refer to any player in my script, not sure if this is how you do it though.
local player = game.Players.LocalPlayer
However when I ran this script which changes walkspeed this is the error I get, "attempt to index nil with 'Character'" I'm not completely sure what this means, but when I searched it up I found a suggestion to someone else with the same error to switch to local script (Random question: I thought that local scripts only work on things on the player and not inside the server that everyone can interact with, is that right?.) Local script did not give me an error, instead when I touched the brick nothing happened.
part = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
player.character.Humanoid.WalkSpeed = 150
end
end)
Thank you for reading.

2 comments
Make sure you capitalised Character.
Alright, thank you