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?
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)
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)
Your issue is that you are changing the belt value client side
Have a look at this code snippet here
lua
Equip.MouseButton1Click:Connect(function()
local TheText = Chosen:WaitForChild("TextLabel")
local TheBelts = RewardedBelts:GetDescendants()
BeltValue.Value = TheText.Text
Remote:FireServer()
InventoryGui.Enabled = false
end)
It is being changed from the LocalScript
.
You can pass the text of your TextLabel
to the server, and have the server set the Value
of BeltValue
to whatever was received
Sort of like this:
lua
remoteEvent.OnServerEvent:Connect(function(client, value)
beltValue.Value = value;
end);
With proper security checks of course