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

Why am I getting this error when trying to fire the client (RemoteEvents)? [ANSWERED]

Asked by 5 years ago
Edited 4 years ago

So to preface this I'm fairly new to using RemoteEvents, and I'm definitely understanding something wrong, but I'm not sure what. Here's what I'm trying to do: This is in a local script in the StarterGui:

local locp = game.Players.LocalPlayer
function handsomemessage(msg)
local gui = locp.PlayerGui.HandsomeGui.MessageFrame
gui:TweenPosition(UDim2.new(0.193, 0, 0.848, 0), "Out", "Elastic", .75)
local messagegui = gui.Message
for i = 1, #msg do
messagegui.Text = string.sub(msg, 1, i)
wait()
end
wait(2)
gui:TweenPosition(UDim2.new(0.193, 0, 1, 0), "In", "Back", .25)
messagegui.Text = ""
end
game.ReplicatedStorage.CamEvents.HandsomeMsgOnly.OnClientEvent:Connect(handsomemessage)

Now in another script (not a local script) within the workspace I'm attempting to fire this event with something similar to this:

--this is normally within a function but I'm freehanding here
local handsomeevent = game.ReplicatedStorage.HandsomeMsgOnly
local message = "Hi how are ya"
handsomeevent:FireClient(message)

I figure I'm doing something incorrectly with trying to use the parameter of my handsomemessage function and trying to transfer info from the script to the localscript and I figure this is what I'm misunderstanding the use of. The error I get is:

Unable to cast value to Object

Any ideas? Clarifications? Thanks for any help. Edit: Well, I did some digging by looking up the error and found that I should be using :FireAllClients(), which is good because it means I at least have some idea what I'm doing. Will mark this as answered.

Edit 7 months later: Hey, I'm coming back to this real quick just to say that I didn't know you could pass the intended client in :FireClient() so please don't use this for reference if you somehow find it. Although in this case :FireAllClients() was appropriate because I was trying to reach them all.

Answer this question