I have a string value inside of my character and I want to use a :GetPropertyChangedSignal function on it. The problem is, my character sometimes reloads and so does the string value. How do I do this?
Does it really need to be inside the character? Depends on what you’re trying to achieve, but you can just parent the StringValue to the player and also have an easy way to get its owner.
I guess I could of put it inside of the player, but I already have like 100 scripts that use the character to locate it and I don’t have time to change all of it. I have never had any problems with this, but now is where I need help.
Maybe try using GetDescendants in a for i, v loop to look for the string value every time the character reloads. Here’s a script:
--//Services
local Players = game:GetService("Players")
--//Variables
local StringValue
--//Functions
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
for i, child in ipairs(Character:GetDescendants()) do
if child:IsA("StringValue") and child.Name == "MyStringValue" then
StringValue = child
print(StringValue)
StringValue:GetPropertyChangedSignal("Value"):Connect(function()
print("Value has been changed.")
end)
end
end
end)
end)