Help with Starter gear

So, I’m trying to make a gui that permanently gives you a tool once you click it. The problem is, although the tool goes to the player’s backpack and the player’s starter gear, it doesn’t give the player the tool once the player dies.

local button = script.Parent.TextButton
local tool = game.ReplicatedStorage.ClassicSword
local player = game.Players.LocalPlayer

button.MouseButton1Up:Connect(function()
	local ctool = tool:Clone()
	ctool.Parent = player.Backpack
	local ctool = tool:Clone()
	ctool.Parent = player.StarterGear
	
end)

It doesn’t give you the tool because this is a localscript. You need to parent the tool to the StarterGear in a server script.

So do I use a remote event? If yes, can you tell me how I can use it? I know how remote functions work but I don’t know how to use them efficiently

Yes. You should use a remote event. Remote events automatically pass the player, so you can do something like

Remote.OnServerEvent:Connect(function(player)

end

Oh yea it works now, thanks. Just wondering, how can I make the script work when I make multiple buttons(and each buttons will give you a different tool)? Sorry if I’m asking for a lot, I’m new to remove events and I’m willing to learn more about it

Define a new variable for the other button and make a new function for when that one has been pressed

So, will something like this work?

local script:

local tool_type = "Gun"
event:FireServer(player, tool_type)

server script:

event.OnServerEvent:Connect(function(player, tool_type)
if tool_type = "Gun" then
    local tool = game.ReplicatedStorage.Gun
    local ctool = tool:Clone()
    ctool.Parent = player.Backpack
    local ctool = tool:Clone()
    ctool.Parent = player.StarterGear
end
end)

Hello There! Please, Change your Display name. I might Flag you about it. Thanks!

Hi. I Have changed my display name a long time ago. Display names dont update on the dev forum though. :frowning_face:

It can change, Just Log out then Log in back. That’s how we change ourselves here on Roblox Developer Forum.

1 Like

how do i log out on the dev forum

Nvm, Figured it out. Thanks!