I'm making a shop where a player can click on a mannequin's clothes and get information on the clothes, buy the product, or add it to a cart to try on. I set up a RemoteFunction called OpenItemCard in the ReplicatedStorage and whenever the player clicks on clothes, I want the script to invoke OpenitemCard to send information from the mannequin to the client. Whenever I click on the mannequin all that shows up on output is "Unable to cast Instance to int64," and the cause of the error is at "Script 'Workspace.Mannequin.ShirtPurchase.ClickDetector.WhenClicked', Line 5," and "Script 'Players.BronzedMocha.PlayerGui.ItemCard.InfoLoadInScript', Line 15" What do?
server side script (line 5 mentioned above is line 5 below)
Adornee = script.Parent.Parent.Parent.AdorneeAnchor ShirtID = string.sub(script.Parent.Parent.Parent.Body.Shirt.ShirtTemplate, 14) script.Parent.MouseClick:connect(function(plr) print("Click Detected") game.ReplicatedStorage.OpenItemCard:InvokeClient(plr, ShirtID, nil, Adornee) print("Client Invoked") end)
here's the remote function being called on the client side (line 15 mentioned above is line 15 below)
OpenItemCard = game.ReplicatedStorage:WaitForChild("OpenItemCard") function OpenItemCard.OnClientInvoke(player,ShirtID,PantsID,Body) local function ShirtorPants() if ShirtID then return ShirtID else return PantsID end end local Card = script.Parent.ItemInfo local CardHolder = script.Parent local Asset = game:GetService("MarketplaceService"):GetProductInfo(ShirtorPants())
Line 3 of your local script. The OnClientInvoke does not have a player argument. Although the player must be specified in InvokeClient, not on OnClientInvoke.
So make line 3 look like this:
function OpenItemCard.OnClientInvoke(ShirtID, PantsID, Body)