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

Gui based tool giver?

Asked by 9 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)
Ad
Log in to vote
0
Answered by 2 years ago

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)

Answer this question