hey, developers. i am making a tower defense game and im stuck in this code which I want to reference the String value that is stored in the LocalPlayer and i want to put the string values which is the tower names into the hotbar in StarterGui but it keeps giving me this error again and again
for i, v in pairs(game.Players.LocalPlayer:GetChildren()) do
wait(1)
if v:IsA("StringValue") then
player[v.Name].Changed:Connect(function()
wait(1)
print(v)
print(v.Name)
print(v.Value)
local TowerName = v
script.Parent[v].TowerName.Value = TowerName:WaitForChild("Value")
end)
end
end
the error is
Players.DaRealHotSauce.PlayerGui.Hotbar.HotbarFrame.Monitor:20: invalid argument #2 (string expected, got Instance) - Client - Monitor:20
this line of code specifically is the one that is giving me the error
script.Parent[v].TowerName.Value = TowerName:WaitForChild("Value")
if you can figure out why it’s broken, please leave a suggestion. also, i’m very new to scripting.

6 comments
yeah i got the same problem
didn't you mean TowerName:WaitForChild("Value").Value ?
thanks for the help but it still doesnt work. still gives me the same error.
Try remove waitforchild('value'). It can be that there is a children 'Value' inside a Value Object
still doesnt work. still has same error
Well, the point of the error is that you set a value to a instance instead of a string.