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

RemoteFunctions erroring "Unable to cast value to Object", what does this mean?

So, I'm creating a system like Roblox Anti-Exploit/Roblox Developer Services, and I have a RemoteFunction inReplicatedStorage called 'Call'.

Here's the code from my ModuleScript:

function callESAE(name,id,desc)
	local rep = 'yay'
	
	--http stuff yeye
		--Insert trello API code
		
	--responce
	if rep == 'yay' then
		sendMsg("Call System","Your call to ESAE has been sent.\nPlease wait, an agent will be with you shortly.",player,true) --title, body, player, canClose
	elseif rep == 'l01a was here' then
		sendMsg("Call System","You allready have a pending EASE call.\nYour call has not been sent.",player,true) --title, body, player, canClose
	elseif rep == 'bad boi' then
		sendMsg("Call System","You have been banned from calling ease.\nYour call has not beens sent.",player,true) --title, body, player, canClose
	elseif rep == 'crosstect is here' then
		sendMsg("Call System","The game you are playing has been blacklisted from calling ESAE.\nYour call has not been sent.",player,true) --title, body, player, canClose
	else
		sendMsg("Call System","An unkown error has occoured, please contact ElmEditor.\nYour call has not been sent.",player,true) --title, body, player, canClose
	end
end

--

function alert.OnClientInvoke(player,desc)
callESAE(player,desc)
end

And here is the code in my local script (I have defined what theRemoteFunction is with WaitForChild)

reqframe.Submit.MouseButton1Click:connect(function()
	local reason = reqframe:WaitForChild("Reason")
	cevent:InvokeClient(tostring(reason.Text)) --This is line 267
end)

And here's the error:

10:18:39.781 - Unable to cast value to Object 10:18:39.781 - Script 'Players.Player.PlayerGui.ES_CmdUtl.Client', Line 267 10:18:39.782 - Stack End

1 answer

✓ Accepted answer

I'll assume that sendMsg is a proxy to some other API call. Which is a bit confusing, because you shouldn't need the player unless it's on the server. You also appear to be hiding a lot of your code and you're missing the parts which are erroring.

You're only passing 2 arguments to callESAE, however callESAE appears to have 3 parameters. Not only that, but your arguments don't appear to match up to the parameters. You're also calling sendMsg with some nil arguments, as the variables used in the arguments don't appear to be defined at the time of reference.

In all, there's a lot wrong with this, and there's not nearly enough to solve this. Get the right code, and we can have a look.


(Psst, you need a Player as the first argument to InvokeClient)

5 comments

0

Thanks, I will try that out

0

Damn. When I get ninja'd by you editing in an actual bit of code and the error whilst I'm writing my answer.

0

I'm not going to accept this as the answer until I can prove that it is working. As there are no errors, so I am going to get it to print if it worked. Once again, thanks for the answer.

0

It might not work, but it's definitely the reason. It might not work because in honesty your logic and code is poorly considered.

0

It worked, thanks for the answer.

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