Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My button wont find the input of my textbox?

Ok so basicly im trying to make it so when I click a button it checks the text in a textbox then searches that inside my players backpack and clones the tool with the text in the text box. ex. TextBox text says "BasicAxe" then I click the button and it looks for something called that in my player backpack and clones it so I have two.

If you need more info on what stuff is or looks like i'll respond with the info.

1 answer

✓ Accepted answer

To do this via a local GUI, you must use the server so that you have the tool for all clients/server.

You will need a localscript, RemoteEvent in replicatedStorage, and a script in serverScriptService.

The localscript should look like this:

local textbox = script.Parent.Parent.TextBox -- Location of textbox


script.Parent.MouseButton1Click:connect(function() --On click
    local toolName = textbox.Text --Takes string of text box
	game.ReplicatedStorage.cloneGear:FireServer(toolName) -- Fire event called "cloneGear"
end)

This is the server side script

game.ReplicatedStorage.cloneGear.OnServerEvent:Connect(function(plr, toolName)
	local tool = plr.Backpack:FindFirstChild(toolName)
	if tool ~= nil then
		local newTool = tool:Clone()
		newTool.Parent = plr.Backpack
	end
	
end)

To change it to search in server storage, change the 2nd line of server side, changing it to

|Location|:FindFirstChild(toolName).

Hope this helps :)

2 comments

0

Where does the localscript go? I didnt pick that up.

0

nvm

This discussion is preserved as it was. New answers, comments, and votes are closed.