Value returning nil when it shouldn't

Hello

This is my code, so when I check in Client it works, the trouble is at ‘Folder’ It says Infinite Yield on Replicated Storage for waiting the squad owner name.
Here you can see, the value is true, everything’s perfect, tweening GUI but…
https://gyazo.com/530e653b4fcf823a88604062d39a7582
it’s not giving billboard gui,
image
The funny part, is that, first off folder exixts. image
second: https://gyazo.com/eede7ff628305e3155ddf6e249b9f79a Here i’m checking clientsided the value, but for some reason, the local script is getting the value as nil

WHAT IT SHOULD DO:

Basically, give billboard gui to player, but looks like if the SquadLeader.Value was nil

Player["Status"]:FindFirstChild("InSquad").Changed:Connect(function(value)
	
	if value == true then
		script.Parent.OnSquad:TweenPosition(UDim2.new(0,0,0,0), "Out", "Quad", 1, true)

				print("Changed")
			local Folder =  game.ReplicatedStorage:WaitForChild(Player.Status.SquadLeader.Value.."-Squad")
			ClearTags()
			if Folder then
				print('Folder~')
			for i,v in ipairs(Folder:GetChildren()) do
				print(v.Name)
				if v ~= Player.Name then
					local Template = script:FindFirstChildWhichIsA("BillboardGui"):Clone()
					
						Template.Name = v.Name 
						Template.Adornee = workspace:FindFirstChild(v.Name:WaitForChild('Head'))
						Template.Parent = script.Parent.Teamtags
				end
			end
			end

			
	elseif value == false then
			ClearTags()
		script.Parent.OnSquad:TweenPosition(UDim2.new(-1,0,0,0), "Out", "Quad", 1, true)
	end
end)	

Any question ask please :slight_smile:

1 Like

well, while "Player1-Squad" exists… the folder called "-Squad" does NOT exist.

local Folder =  game.ReplicatedStorage:WaitForChild(Player.Status.SquadLeader.Value.."-Squad")

your SquadLeader value is empty maybe?

Player.Status.SquadLeader.Value
1 Like

Nope, https://gyazo.com/eede7ff628305e3155ddf6e249b9f79a here you can see.

1 Like

is your script a server script or local script?

also is your value being set by a server script or a local script?

EDIT: if your setting the value with a local script, then the server wont see the change unless you replicate it.

1 Like

Is a script, and im setting it from server sided script

1 Like

oh, then maybe its just a hierarchical problem, try double checking your directories to the values and folders.

1 Like

What do you mean? 30 charssss :hear_no_evil:

1 Like

What @codyorr4 is saying is for you to check if your script is getting the values correctly.

1 Like

Well, I think so, look


It’s printing targeting name so

game.ReplicatedStorage.OOP.AddToSquad.OnServerEvent:Connect(function(plr, Target)
	if Target then
	if game.ReplicatedStorage[plr.Name.."-Squad"]:FindFirstChild(Target.Name)  then return end
		if Target['Status']['InSquad'].Value == false then
		game.ReplicatedStorage.OOP.AddToSquad:FireClient(Target, plr)
		end
	end
end)

CLIENT:

game.ReplicatedStorage.OOP.AddToSquad.OnClientEvent:Connect(function(TheOneAsking)
	print(TheOneAsking.Name)
	script.Parent.SquadPrompt.ViewGuns:TweenPosition(UDim2.new(0.405, 0,0.092, 0), "Out", "Quad", 1, true) 
	script.Parent.SquadPrompt.ViewGuns.TextLabel.Text = "Hey "..Player.Name.." would you like to join "..TheOneAsking.Name.." squad?"
end) 

When clicking yes:

script.Parent.SquadPrompt.ViewGuns.yes.MouseButton1Click:Connect(function()
	local Split = script.Parent.SquadPrompt.ViewGuns.TextLabel.Text:split(" ")
	print(Split[2].." "..Split[8])
    game.ReplicatedStorage.OOP.Yes:FireServer(game.Players:FindFirstChild(Split[8]))
script.Parent.SquadPrompt.ViewGuns:TweenPosition(UDim2.new(0.405, 0,-0.3, 0), "Out", "Quad", 1, true) 

end)
1 Like

You’re listening for a change on “InSquad”. I can’t see what code is setting the “SquadLeader” Value, however I suspect it goes something like this:

Player.Status.InSquad.Value = true --A
Player.Status.SquadLeader.Value = SquadLeader --B

The InSquad is set, then your code runs, but it reaches the if statement before SquadLeader is set, so it appears as nil. Perhaps try swapping round those two:

Player.Status.SquadLeader.Value = SquadLeader --B
Player.Status.InSquad.Value = true --A
2 Likes