LocalScript
main:WaitForChild("giveBtn").MouseButton1Down:connect(function() re:FireServer("giveTicket",main:WaitForChild("main")) end)
Server Script
re.OnServerEvent:connect(function(plr,event,main) if event == "giveTicket" then print(main.Name) end end)
"main" is a Frame that I want to pass to a Server Script so the script can grab text from it and it keeps outputting this
ServerScriptService.TicketSystemHandler_ss:15: attempt to index local 'main' (a nil value) Script 'ServerScriptService.TicketSystemHandler_ss', Line 15 Stack End
I know the variables definitely exist since I can print their names in the LocalScript, can anyone help? If you need the full script just ask
Anything created on the client remains only on the client. When using StarterGui to provide the client with GUI, the parented Instances are cloned locally to the player's PlayerGui. Your current script passes an Instance that exists only on the client into re:FireServer()
. When the server receives the signal, the argument will be nil.
Simply pass the value of main.Name
itself, or any other property of the Instance that you need.
RBXScriptSignal:connect()
is deprecated in favour of RBXScriptSignal:Connect()
.main:WaitForChild("giveBtn").MouseButton1Down:Connect(function() re:FireServer("giveTicket", main:WaitForChild("main").Name) end)
re.OnServerEvent:Connect(function(plr, event, main_name) if event == "giveTicket" then print(main_name) end end)
I hope this helped!