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

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

Asked by 6 years ago

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)
0
try printing val and txt to see what they actually are (to make sure they are the right thing) abnotaddable 920 — 6y
0
I can't cause when i try it gives me that error again ObStactionD3stroy3r 14 — 6y
0
use tostring abnotaddable 920 — 6y
0
I have never used that so don't know how to ObStactionD3stroy3r 14 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question