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

Why the client passing nil to the server (Remote Event) ?

Asked by 5 years ago

When printing the copyCard in the Local Script there are an output (Feral Imp) but when the copy card is passed to the server its become nil why ? and how to fix ?

local script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local transfateToDeckEvent = ReplicatedStorage:WaitForChild("TransfateToDeckEvent")
card = script.Parent.Parent

local copyCard = card:Clone()
print("client output : ",copyCard)
transfateToDeckEvent:FireServer(copyCard)

script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local transfateToDeckEvent = Instance.new("RemoteEvent", ReplicatedStorage)
transfateToDeckEvent.Name = "TransfateToDeckEvent"

local function transfareToDeck(player, Args)
    print("server output : ",copyCard)
end

transfateToDeckEvent.OnServerEvent:Connect(transfareToDeck)

This is the output:

client output : Feral Imp server output : nil

1 answer

Log in to vote
1
Answered by
gullet 471 Moderation Voter
5 years ago

You're creating a clone in the localscript, anything done in a localscript will only happen for the client, the clone doesn't exist on the server, when you then pass that as an argument it will look for it on the server but it will not exist.

0
I would also like to add that the the wrong name (server-side) is being used to refer to the card. RayCurse 1518 — 5y
0
Thanks belalg1 9 — 5y
Ad

Answer this question