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

Why won't my boolean value change?

I made a script to change a boolean value from false to true when the robux value was greater than or equal to 100. But im getting the error: 15:43:41.837 - Players.CarmiteStars.PlayerGui.Menu.MenuFrame.AdvancementOpener.AdvancementFrame.Adv2.Adv2Script:1: attempt to index field 'LocalPlayer' (a nil value)

while true do

wait()

local player = game.Players.LocalPlayer

local robux = player:WaitForChild("stats"):FindFirstChild("robux")

local adv1 = player:WaitForChild("adv"):FindFirstChild("adv1")

if adv1 and robux then

if robux.Value >= 100 then

adv1.Value = true

end

end

end

If you could explain that would be great.

3 comments

0

Local Script?

0

Have you tried local player = game.Players:WaitForChild("LocalPlayer")

0

@AltNature, Unless there is a player named "LocalPlayer", that wouldn't work. LocalPlayer should always exist because the PlayerObject itself is needed to run Local Scripts. The reason this doesn't work is probably because you used a server script rather than a local script.

2 answers

Just had to change the script to a local script. Thanks commenters!

Its cause it a local script or if its a regular script then find the player some other way because. game.Players.LocalPlayer only works for local scripts. Also if u change a value for a localscript only scripts local to that player can see it

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