I am trying to make it so that when you press a button, you get a tool put in your backpack. I'm really new to programming with FE on, so I don't know what the problem is with this code:
Script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage) createPartEvent.Name = "GiveTool" local function give(player, obj) a = obj:Clone() a.Parent = player.Backpack end createPartEvent.OnServerEvent:Connect(give)
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage") local createPartEvent = ReplicatedStorage:WaitForChild("GiveTool") script.Parent.MouseButton1Down:connect(function() createPartEvent:FireServer(game.Players.LocalPlayer, script.Parent.Parent.obj.Value) end)
Please help.
The player is automatically sent to the server so no need to define it when sending. This is what is breaking your script.
createPartEvent:FireServer(script.Parent.Parent.obj.Value)