I have a LocalScript that fires a remote and changes the value of a StringValue. I have a script that finds that the remote was fired and finds the value. It goes through a list of items until the name matches the value, it then places it into the Workspace. In output I'm finding out that the script is not even recognizing that the StringValue's value has even changed at all. How do I fix this?
The LocalScript
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RewardedBelts = ReplicatedStorage:WaitForChild("Belts")
local InventoryGui = PlayerGui:WaitForChild("InventoryGui")
local Scroll = InventoryGui.Inventory.ScrollingFrame
local Equip = InventoryGui.Inventory.Equip
local Chosen = InventoryGui.Inventory:WaitForChild("Selected")
local Workspace = game:GetService("Workspace")
local BeltValue = Workspace:WaitForChild("BeltValue")
local Remote = ReplicatedStorage:FindFirstChild("Opened")
Equip.MouseButton1Click:Connect(function()
local TheText = Chosen:WaitForChild("TextLabel")
local TheBelts = RewardedBelts:GetDescendants()
BeltValue.Value = TheText.Text
Remote:FireServer()
InventoryGui.Enabled = false
end)
The Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game.Workspace
local RewardedBelts = ReplicatedStorage:WaitForChild("Belts")
local BeltValue = Workspace:WaitForChild("BeltValue")
game.ReplicatedStorage.Opened.OnServerEvent:Connect(function(player)
print("Connected")
local TheBelts = RewardedBelts:GetDescendants()
for i,v in pairs (TheBelts) do
if v:IsA("UnionOperation")then
print(v.Name.. " is usable")
if BeltValue.Value == "Blank" then repeat wait() until BeltValue.Value ~= "Blank"
print(BeltValue.Value.. " is the BeltValue")
if v.Name == BeltValue.Value then
print("Found" ..v)
local R = v:Clone()
R.Parent = game.workspace
print("The Belt has been placed in the workspace.")
end
end
end
end
end)

1 comment
Values have a Changed property.