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

Gui based tool giver?

How would I make a ImageButton, or a TextButton be able to give you custom tools, like soda, guns, etc? I have the Gui and image buttons, but I need the script to give the tools.

2 answers

Well, you'd need to get down some events and the cloning method.

--Local Script
plr = game.Players.LocalPlayer
tool = game.ServerStorage["Tool name here"]

script.Parent.MouseButton1Down:connect(function()
	tool:clone().Parent = plr.Backpack
	--tool:clone().Parent = plr.StarterGear
end)

Go to replicated storage then create Remote Event. Name the Remote event to ToolGiverEvent or any

Put this local script in gui button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")


script.Parent.MouseButton1Click:connect(function()
		ReplicatedStorage.ToolGiverEvent:FireServer() -- Change the "ToolGiverEvent" to the remote event name
	end)

Then put this in ServerScriptService:

	game.ReplicatedStorage.ToolGiverEvent.OnServerEvent:Connect(function(plr) -- Change the "ToolGiverEvent" to the remote event name
		game.ServerStorage.ToolName:Clone() -- Change the "ToolName" to the name of the tool
	game.ServerStorage.ToolName:Clone().Parent = plr.Backpack -- Change the "ToolName" to the name of the tool
	end)

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