✓ Accepted answer
How to make this
You need to use RemoteEvents to Replicate tool to Player, also the tool can't be in GUI, put in ReplicatedStorage in a folder of tools...
How to use RemoteEvents
local RemoteEvent = ...
RemoteEvent.OnServerEvent:Connect(function(player,argument)
if argument == "CreatePart" then
Instance.new("Part").Parent = workspace
end
end)
local RemoteEvent = ...
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer("CreatePart")
end)
RECOMMENDATION
Stop with using :connect this is deprecated, for new work use :Connect also, stop with using :clone too, use :Clone
FIXED SCRIPT
Create a RemoteEvent in ReplicatedStorage, also create a Folder named as "Tools" in this folder put all tools
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local tools = game.ReplicatedStorage.Tools
RemoteEvent.OnServerEvent:Connect(function(player,toolName)
local Backpack = player:FindFirstChild("Backpack")
local StarterGear = player:FindFirstChild("StarterGear")
if Backpack and StarterGear then
local tool = tools:FindFirstChild(toolName)
if tool then
tool:Clone().Parent = Backpack
tool:Clone().Parent = StarterGear
end
end
end)
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer("Sword")
enn)
Hope it helped :)
2 comments
Thanks this helped a lot.
Also do you know if there is away to make it delete the old tools in the backpack and Startergear and then copy the new once over?