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

Unable to cast value to Object?

why is this not working? i have no idea how to fix please help.

here is script:

local remF = script.Parent.ram
local Name = game.Name

local https = pcall(function()
	game:GetService('HttpService'):GetAsync('https://www.google.com/')
end)


local success, failed = pcall(remF:InvokeClient(Name, https))

if success == true then
	print('Worked')
end

if failed == true then
	error('Error: Failed To Send')
end

the error is coming from Line 9

1 answer

Your problem on line 9 is that the first input is actually supposed to be the Player from "game.Players" that you want to send the request to. You can just switch that up to ":InvokeClient(Player, Name, https)" which should solve your issue.

If you have any questions or issues contact me. ;)

10 comments

0

the player thing works thanks but the Name and http when it goes to the localscript i wanted to get teleported to one of my other games to give that data too but it always comes up with nil when its printed. do you know a fix?

0

Since you are using "RemoteFunctions" I just want to make sure that in your LocalScript when you say "remF = function()" to make sure that the first two parameters are actually there such as "remF = function(name, https)" but also make sure that you aren't including "Player" within it. The "Player" is only for invoking and never gets sent to the actual LocalScript function.

0

yh dw i didnt put in Player with Name, http even so i still get nil when sent to the other game

0

Make sure "HTTPService" is enabled in your other game. I'm quite unsure why it would return nil for game.Name; maybe you could do wait() as it might not have loaded in yet.

0

its still saying nil, maybe its something to do with my other game?

0

idk if this will work but its the same script but i changed it abit, i added local plr = game.Players:FindFirstChildOfClass("Player") and with remF:InvokeClient(plr, https)

0

So it seems that either you are incidentally trying to find multiple instances of "Player" or you're trying to send the request to all the players. If you're trying to send a request to all the players I reccomend using "RemoteEvents" and then using "FireAllClients()" but it would be easier if you just use ".OnPlayerAdded:Connect(Plr)" and use that instead.

0

I also don't reccomend using "RemoteFunctions" on the server side because the script could pause and wait indefinitely until it gets a value from the client (and could possibly yield forever).

0

then could i use coroutine.create() then do coroutine.resume? or coroutine.yield?

0

When you use something like ".OnPlayerAdded" it would run on a per-player basis so there wouldn't need to be any worries about coroutines.

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