Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to find the value of a stringvalue in serverstorage?

Asked by 6 years ago

Didn't really do the title that well, here's an example of what I need help making.

So the StringValue = TextButton.Text which works fine, in my case the value would be "Bacon and Eggs" or something like that and there is a tool in ServerStorage called "Bacon and Eggs".

So in a nutshell what I want is for a TextButton to read the StringValue.Value which is "Bacon and Eggs" and search for "Bacon and Eggs" in ServerStorage then clone the tool into the player's backpack. The reason why I just don't do game.ServerStorage.["Bacon and Eggs"] is because I've set the script to do for each tool in ServerStorage a TextButton will be cloned and have the tool name in ServerStorage. If you need me to explain if you're confused then just ask c:

0
So, you're asking for a script that loops through every tool in ServerStorage, cloning a button each time with the name of the tool? sodaghost1 34 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

So, you basically want to clone once the text is on the TextBox? Put this in a ServerSide script, in any place really, like ServerScriptService.

game.Players.PlayerAdded:Connect(function(Player)
    Player.PlayerGui.Gui.TextBox.FocusLost:Connect(function(text) -- Change Gui and Textbox with the textbox parent
        for i,v in pairs(game.ServerStorage:GetChildren()) do
            if v.Name == text then
                v:Clone().Parent == Player.Backpack
            end
        end
    end)
end)
0
Here you go, buddy, hope it works. Tio_Kills 5 — 6y
0
that won't work if FE is enabled, because the server can't access existing objects within PlayerGui Gey4Jesus69 2705 — 6y
Ad

Answer this question