Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

attempt to index nil with 'LocalPlayer'

so basically i was making a power up script until its error showed up: Workspace.Part.Script:5: attempt to index nil with ‘LocalPlayer’. Also im new to all of this so i dont really have the best clue on why this happened.

heres the script:

`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.MaxHealth = math.huge 
        hit.Parent.Humanoid.Health = math.huge 
        Players.LocalPlayer.Character.Humanoid.WalkSpeed = 36
        Players.LocalPlayer.Character.Humanoid.JumpPower = 10
    end
end)



`

To be honest not much. I tweaked some grammar and stuff nothing helped though.

type here

>Solution :

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.MaxHealth = math.huge 
        hit.Parent.Humanoid.Health = math.huge 
        hit.Parent.Humanoid.WalkSpeed = 36
        hit.Parent.Humanoid.JumpPower = 10
    end
end)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading