Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I fix this error on line 5? LocalPlayer = nil value / player = nil value

https://gyazo.com/c868fe5722917c1c6cef3c335da43b50 https://gyazo.com/9cad2185947b4ce68d07aef6ba8f66f1 http://prntscr.com/mmuopt https://gyazo.com/03419319048d4ecb74d4d7a82b8eb3f5

When walking up to the stage1 brick it does nothing. It doesn't show the gui and make it visible please help. There is an error on line 5. Please Help.

script.Parent.Touched:Connect(function()
    local player = game.Players.LocalPlayer
    if player.leaderstats.Stage.Value <= 0 then
    player.PlayerGui.stage.stage1.Visible = true
    elseif player.leaderstats.Stage.Value >= 0 then
        game.Workspace.stage1door:Destroy()
    end
end)

13 comments

0

is script a localscript?

0

^

0

no

0

Then that's the problem. It must be a localscript, if you want to detect the leaderstats.Stage, except if you use RemoteEvents.

0

Can u use a localscript instead of an remoteevent

0

Yes you can. But that would cause some issues (example a script tried to call the GUI but its local).

0

You can only call :FireServer() from a localscript.

0

its not working still

0

Your trying to get a localplayer from a script. Use :GetPlayerFromCharacter() and it should work.

0

k let me try

2 answers

✓ Accepted answer

Please make sure that this is located inside of a LocalScript!

I'm assuming you know how to define a part from inside of the workspace. So make a localscript inside of StarterPlayer > StarterPlayerScripts

Inside of this script you can put the following code, Where it says "PARTNAME" on line one, put your part.

local Part = game:GetService("Workspace"):FindFirstChild("PARTNAME")
Part.Touched:Connect(function()
	local player = game.Players.LocalPlayer
	if player.leaderstats.Stage.Value <= 0 then
		player.PlayerGui.stage.stage1.Visible = true
	elseif player.leaderstats.Stage.Value >= 0 then
		game.Workspace.stage1door:Destroy()
	end
end)

If this helped you then please mark it as the solution!

Why is this not answered! Someone already said it must be a local script to find a localplayer!

This discussion is preserved as it was. New answers, comments, and votes are closed.