So I am busy making an oop inventory system and I am making it so that the players can drop items,
On the client this function is called:
function Slot:DropItem(Player)
print(Player.Name)--Prints my name
if self.Item then
if self.UsedSlots - 1 ~= -1 then
local Item = Items[self.Item]:Clone()--There is a table tat contains the items
print("Fire")
print(Item)--Prints the items name
game.ReplicatedStorage.Drop:FireServer(Player, Item)
self.UsedSlots = self.UsedSlots - 1
if self.UsedSlots == 0 then
self.Item = nil
end
end
end
end
And then on the server this happens:
game.ReplicatedStorage.Drop.OnServerEvent:Connect(function(Player, Item)
print(Player.Name)--Prints my name
print(Item.Name)--Prints my name
end)
The client:
for i, slot in pairs(InventoryFrame:GetChildren()) do
if slot:IsA("Frame") then
slot.Button.MouseButton2Click:Connect(function()
print("Dropping item")
print(slot.name)
Slots[slot.Name]:DropItem(Player)
refreshSlots()
end)
end
end
It is because Remote events by default pass on the Player instance as the first argument themselves for OnServerEvent, so you don’t need to pass it again from the client, otherwise obviously it would have been so easily exploitable.
Even so, network usage can increase significantly, which can lead to lag for those using low-speed networks.
Please make item number and use the item number.
If you send a client sided instance, it will be nil to the server and that is obvious. And @SpacialEthanRB yeah, you should pass the Item name / a different type of reference, as a client sided instance will be nil to the server as I said above.
I didn’t really check out the other part of the script, as the OP’s question was why it was printing the same I believe
Instances can be passed through remotes so long as both sides can see the said instance. An instance created on the client will obviously return nil if indexed on the server, but indexing the workspace (assuming that was the passed argument) will return the workspace.
As long as there aren’t backdoors in the game, hackers will be only creating the parts in their side, meaning no one else can see it. So it will be nil for the server too.
Except if the game in question has poor security implemented, this will not be the case as anything created on the client will not replicate to other clients or the server without explicit usage of remotes.
I recommend that you look into Roblox’s article on the Client-Server Model before spreading potentially inaccurate information.