But I want the card to work on doors, which is not working.
local p = game.Players.LocalPlayer local button = script.Parent local backpack = p.Backpack local tool = game.ReplicatedStorage:WaitForChild("Room 101") button.MouseButton1Click:connect(function() local nTool = tool:Clone() nTool.Parent = backpack end)
This is code is in a local script inside a button.
Your issue is related to Filtering Enabled
. Because you're adding the tool to the client's Backpack
via a local script, the change will not be replicated to the server. To fix this, you simply need to utilize a Remote Event
to tell the server to make the action once the MouseButton1Click
event is fired.
--Server Script local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remote = Instance.new("RemoteEvent") local Remote.Parent = ReplicatedStorage --create remote Remote.OnServerEvent:Connect(function(player,tool) local NewTool = tool:Clone() NewTool.Parent = player.Backpack end)
--Local Script local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remote = ReplicatedStorage:WaitForChild("RemoteEvent") local button = script.Parent local tool = ReplicatedStorage:WaitForChild("Room 101") button.MouseButton1Click:Connect(function() Remote:FireServer(tool) --tell the server to clone the tool end)
If you have any questions regarding this code, feel free to leave them in the comments. I'm happy to answer!