I want to throw an item using a remote event, but when I fire the event on the client, it returns the item as nil in the event on the server
– client
local CAS = game:GetService("ContextActionService")
local item = nil
local button = script.Parent
for i, v in pairs(button:GetChildren()) do
if v:IsA("Model") or v:IsA("Part") or v:IsA("MeshPart") then
item = v
end
end
local function Actions(actionName, inputState)
if actionName == ("Throw".. button.ItemNum.Text) and inputState == Enum.UserInputState.Begin then
game.ReplicatedStorage:WaitForChild("Inventory"):WaitForChild("ItemThrown"):FireServer(item)
print(item)
script.Parent.Parent.RemoveItemClient:Fire(item,script.Parent)
button.Parent.Parent.ItemViewport:SetAttribute("ItemName","")
button.Parent.Parent.ItemViewport:SetAttribute("ItemDesc","")
for i, v in pairs(button.Parent.Parent.ItemViewport:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("Model") then
v:Destroy()
end
end
CAS:UnbindAction(("Inspect".. button.ItemNum.Text))
CAS:UnbindAction(("Throw".. button.ItemNum.Text))
CAS:UnbindAction(("Use".. button.ItemNum.Text))
end
end
You cant sent instances over the network. If you want to do something like this then you need to instead fire some kind of shared information between the client and server that they can both use to identify the same instance. For example you could just fire the path of the instance (with GetFullName) and then decode it, or give every item a unique ID attribute. Whatever you do just make sure that it’s secure and exploiters can’t use it to do crazy stuff
okay so i cloned it and put it in replicated storage on the server, sent that to the client and now the server recognises the instance, however, it says none of the properties are a valid member for some reason
are you sending an InstanceHandle on purpose?
regardless it’s sending an InstanceHandle, this is a separate class used to hold instances for sending them across the network boundary. You can use the :Wait() or :Get() methods on the InstanceHandle to retrieve the actual instance reference.