I was going to debug my script real quick with the print function. My script was supposed to get a StringValue’s value, and use that value to look for a child that has the according value as its name. After finding the child, it will print the child’s name.
After I tried to execute it, it gives me an error the line of getting the variable of the child. So I put a if [Variable] then line, and put a warn function if it doesn’t exist. And it doesn’t exist.
(The local function is working fine btw)
I tried using WaitForChild, FindFirstChild. But that’s all there is for me to think of.
local function StandPunched(player)
local Character = player.Character
local Stand = player.Backpack:WaitForChild(player.StandValue.Value)
if Stand then
print(Stand.Name)
else
warn("dum dum")
end
end
game.ReplicatedStorage.StandPunch.OnServerEvent:Connect(StandPunched)
WaitForChild() searches for an object that matches the String argument. If you’re waiting for player.StandValue, then WaitForChild() would search for nil.
local Stand = player.Backpack:WaitForChild("StandValue") -- get the object
print(Stand.Value) -- print the value of the object
Also, your code looks like the StandValue would already be inside the player when the function is called. If so, it would be better to use :FindFirstChild(“StandValue”)
I had to print the name of the child in the player’s backpack to make sure the script is able to configure around with the child. Not the StandValue’s value.