Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

"attempt to index local 'LocalP' (a nil value)" how do i fix this?

Asked by 6 years ago
Edited 6 years ago
01local sp = script.Parent
02local db = true
03local LocalP = game.Players.LocalPlayer
04local Player = LocalP.Character
05local Azarth = script.Parent.Option.Frame.ImageButtonFinalFlash
06local Azarth2 = script.Parent.Option.Frame.ImageButtonFinalFlash2
07local Azarth3 = script.Parent.Option.Frame.ImageButtonFinalFlash3
08local Azarth4 = script.Parent.Option.Frame.ImageButtonFinalFlash4
09local Bot = script.Parent.Parent.Parent.Suit
10local Flash = Bot.Arm1.Middle:WaitForChild("FinalArmCharge")
11local Flash2 = Bot.Chest.Middle:WaitForChild("FinalCharge")
12 
13sp.Touched:connect(function(hit)
14    if hit and hit.Parent:findFirstChild("Humanoid") and db then
15        db = false
View all 29 lines...

this is the whole script but then it tells me "attempt to index local 'LocalP' (a nil value)". any way to counter this?

0
Is this a local script or a script? Prestory 1395 — 6y
0
regular script SirTottenhamcake 22 — 6y
0
it's a script, localplayer is not in scripts because it runs on the server so it doesn't know which player is you, but localscript is on the client. supermariodeadtolive 55 — 6y
0
i changed it to a localscript and still doesnt work but this time doesnt even tell me why it doesnt work SirTottenhamcake 22 — 6y
View all comments (9 more)
0
You realise this code is not meant to do anything this is all just variables Prestory 1395 — 6y
0
this is the first part of the script i didnt put the full thing in as it was the variables that i had a problem with SirTottenhamcake 22 — 6y
0
So can we have the full script? maybe that will help?? Prestory 1395 — 6y
0
there u go SirTottenhamcake 22 — 6y
0
Torso, not Chest supermariodeadtolive 55 — 6y
0
chest is the name of another thing welded to the character & is inside the character model SirTottenhamcake 22 — 6y
0
change "LocalPlayer" to "SirTottenhamcake"  OR put the script in "StarterPlayer" > "StarterPlayerScripts" and change "game.Players.LocalPlayer" into "script.Parent.Parent.Parent.Parent" (works or not works based on your Parenting System) supermariodeadtolive 55 — 6y
0
try debugging it. i am new to Lua, this thing is out of my reach. supermariodeadtolive 55 — 6y
0
script is meant to work by touching a part which clones a gui into the frame SirTottenhamcake 22 — 6y

1 answer

Log in to vote
1
Answered by
arshad145 392 Moderation Voter
6 years ago

Hello,

You seem new to Rbx.Lua.

Things you can learn :

1.LocalPlayer can only be used in a LocalScript.

2.You can use PlayerAdded event to get the joining players.

3.connectis deprecated , it is better to use Connect

01--//This Script must be inside of a part//--
02 
03local db = true
04local part = script.Parent
05local gui = game.ReplicatedStorage:FindFirstChild('Gui')--<< Place the gui you want on that path... script.Parent.Option.Frame.ImageButtonFinalFlash
06local Azarth = gui.Opition.Frame.ImageButtonFinalFlash
07local Azarth2 = gui.Option.Frame.ImageButtonFinalFlash2
08local Azarth3 = gui.Option.Frame.ImageButtonFinalFlash3
09local Azarth4 = gui.Option.Frame.ImageButtonFinalFlash4
10local Bot = gui.Parent.Parent.Suit
11local Flash = Bot.Arm1.Middle:WaitForChild("FinalArmCharge")
12local Flash2 = Bot.Chest.Middle:WaitForChild("FinalCharge")
13 
14part.Touched:Connect(function(hit)
15    if hit.Parent:FindFirstChildOfClass("Humanoid") and db then -- You cannot hit 'nil'
View all 33 lines...

That's all for the script. You need to adjust certain paths and such.

Thank you for reading!

Please upvote this post and accept it as an answer if it helped you.

Ad

Answer this question