I want to make a local script run a function when the value of a string value called "EquippedWeapon" is changed. Here I have a local script which changes the string value upon a TextButton being pressed
local EquippedWeapon = game.Players.LocalPlayer:WaitForChild("EquippedWeapon").Value
Buttons = {
script.Parent.Katana -- Katana is the TextButton
}
Buttons[1].MouseButton1Click:Connect(function()
EquippedWeapon = "Katana"
wait(1)
print("EquippedWeapon")
end)
Now, here's a local script in StarterPlayerScripts which runs a function when EquippedWeapon's value changes.
local Player = game.Players.LocalPlayer
local EquippedWeapon = Player:WaitForChild("EquippedWeapon").Value
EquippedWeapon.Changed:Connect(function()
print("Equipped Weapon value has been changed.")
end)
What should happen is that when EquippedWeapon's value is changed to "Katana", it should print a message. But the error message is this:
"Players.trapiz.PlayerScripts.GearChecker:4: attempt to index field 'Changed' (a nil value)"
Thanks :)

4 comments
I tried it, and there's no error, but it doesn't print the message that should print when the value changes.
Change "EquippedWeapon = "Katana"" to "EquippedWeapon.Value = "Katana"" and see what happens
Yep, that's probably the issue. Happens to the best of us.
The variable EquippedWeapon includes .Value at the end, so that can't be the problem.