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

How do i send text from server to client with Remoteevent?

So i'm trying to send some text from the server side to the client side using remoteevents but i can't to get it working it gives me these errors.

Errors

11:49:59.278 - Unable to cast value to Object
11:49:59.278 - Stack Begin
11:49:59.279 - Script 'ServerScriptService.ChooseMap', Line 32
11:49:59.279 - Stack End

11:49:59.298 - Unable to cast value to Object
11:49:59.298 - Stack Begin
11:49:59.299 - Script 'ServerScriptService.GameScript', Line 46 - global Intermission
11:49:59.299 - Script 'ServerScriptService.GameScript', Line 223

Server Script

game.ReplicatedStorage.ServerRequest.Notification:FireClient("Testing Testing", "Testing2 Testin2")

Client Script

reg.Notification.OnClientEvent:connect(function(val, txt)
	local Noti = script.Parent.Notifications
	Noti.Visible = true
	Noti:TweenPosition(UDim2.new(0.5, -200, 0.9, 20))
	Noti.Text = val
	Noti.Shadow.Text = val
	Noti.DownText.Text = txt
	Noti.ShadowDown.Text = txt
	wait(3)
	Noti:TweenPosition(UDim2.new(0.5, -200, 1, 20))
	Noti.Visible = false
	
end)

4 comments

0

try printing val and txt to see what they actually are (to make sure they are the right thing)

0

I can't cause when i try it gives me that error again

0

use tostring

0

I have never used that so don't know how to

1 answer

✓ Accepted answer

You're attempting to send information from the server to the client. So:

Server -> Client

When using a remote event that is being fired by a server-sided script, and then received by a client-side script you need to provide a player argument.

So, you would change your server-sided script to:

game.ReplicatedStorage.ServerRequest.Notification:FireClient(playerVariable, "Testing Testing", "Testing2 Testin2")

As you can see above I added a variable that's a player object called playerVariable. This variable must be a player object and can be set multiple ways. You can use events (PlayerAdded, PlayerRemoving, etc.) or you can just set it like this:

local playerVariable = game:GetService("Players"):WaitForChild("Player1") -- Player1 is only in studio of course

This is bad practice though and I don't recommend it.

Hope I helped.

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