Bro script not working

idk what happened but my output said
15:23:02.148 Values is not a valid member of PlayerGui "Players.Dan_Ronity.PlayerGui" - Client - Phase1-2:5

weirdly, this is my StarterGui pic
image

and this is Phase1-2 code:

	local Phase1 = Map1["Phase 1"]
		local Pinetrees = Phase1["Pine trees"]

local phasechange = script.Parent.Parent.Parent.Values["Phase change"]

if phasechange.Value == true then
	Pinetrees:SetPrimaryPartCFrame(Pinetrees:GetPrimaryPartCFrame() * CFrame.new (0,-10,0)	)
end

if phasechange.Value == false then
	Pinetrees:SetPrimaryPartCFrame(Pinetrees:GetPrimaryPartCFrame() * CFrame.new (0,10,0)	)
end

Help me lmao. the error is from local phasechange ...

You shud avoid placing localscripts in startergui and instead place them in starterplayerscripts. It might also be due to the fact thr folder isn’t inside a screengui.

1 Like

Hello you should check if Values is in the player gui and if is it try to waitforchild him

I tried to replicate this issue and the only solution to fix the issue was to use WaitForChild, so replace that line of code to

local phasechange = script.ParentParent.Parent:WaitForChild("Values"):WaitForChild("Phase change")
1 Like

Why? Will localscripts not work correctly if I do that?

It isn’t a good practice to put them in there, thts all.

Where did you get this information??

Iam a somewhat experienced scripter, who organizes according to a framework I had created, so I usually put all of the localscripts [Module scripts to be exact, but they function like a client sided script] inside StarterPlayerScripts.

Even if I wasn’t using a framework, I wouldn’t put them inside StarterGui, since most of the more experienced scripters I had come to know use the afore mentioned method.

1 Like

Put Waitforchild, still not work ig
image

i changed the code, oh and u forgot the dot between 2 Parents
lmao

lmao, my man, if i put it in StarterPlayerScript,so i still use it as LocalScript ?

or change into normal script ?

LocalScript, [char limit char limit]

1 Like

char limit ?

wdym, and u sure if i put in StarterPlayerScript works ?

imma try to change all of my codes then…

lmao, it doesnt work, this is another local script

So now it works? If not I mite try to find another solution.

yea, the old code works. but then this doesnt work, i put this into StarterPlayerScript, then change the code local things
(sorry im bad at English)
but still not work, idk why

This is a possible problem that might happen, when u name ur instances make sure they do not contain spaces. So try rechecking the name of Values

I thought Values doesnt have spaces

I’d suggest checking it just in case.

hm, i checked ig (idk if i check it right), ofc it still not work, any solution ?
what if i change name into something else, or this is just a weird roblox studio bug lmao