Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I cast a table to an argument? Is there another way to do this?

I'm trying to transfer a table through a function using arguments, but it says "22:51:19.339 - Unable to cast value to Object" This error occurs on line 9 of the script

In a script in Workspace:

_G.ArrestReason={"Test"}
_G.ArrestTime={}
_G.ArrestNum={}
_G.ArrestOfficer={}


ArrestsEvent=script:WaitForChild("TransferArrests")

ArrestsEvent:FireClient(_G.ArrestReason, _G.ArrestTime, _G.ArrestNum, _G.ArrestOfficer)

In a local script:

EventHandler=game.Workspace:WaitForChild("RemoteEventHandler")
TransArrest=EventHandler:WaitForChild("TransferArrests")

TransArrest.OnClientEvent:connect(function(rsn, waitt, off, num)
	print("Invoked")
	print(rsn)
	_G.LocalArrestReason=rsn
	_G.LocalArrestTime=waitt
	_G.LocalArrestOfficer=off
	_G.LocalArrestNum=num
end)

8 comments

2

Post your code please.

0

Sorry forgot, but there.

0

I don't understand what you're trying to do with the _G table.

0

I'm trying to make two global tables, one on the client side and one on the server side.

0

Well.. the only reason you would be using remoteevents for this is if you had FE on. FE disables client to server communication. The localscript, presumable in the player, is trying to access stuff in the Workspace. Everything is cancelling eachother out so I'm still confused what your goal is lol.

0

LocalScripts can't access global tables that are created in server scripts...

0

He's trying to transfer the global table to get around that. OP, which line is in which script is causing that error?

0

Line 3 of the local script

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.