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

Item in Filtering Enabled not cloning when a GUI button is pressed?

Asked by 6 years ago

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.

0
bump GoodTimmyTurner5 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
Ad

Answer this question