I can't send string by remoteEvent. Error: Unable to cast value to Object

I want to send the string form Table in ServerScript to LocalScript in
StarterGui.ScreenGui.Flame.TextLabel by remoteEvent

Server script (Named Quests) :


local rs = game:GetService("ReplicatedStorage")
local button = script.Parent.ProximityPrompt
local event = rs.Remotes:WaitForChild('RemoteDialogText') 

local Quest = 60



local DialogsData = {
	
	
	nic0 = "nie ma questa w domu ",
	text2 = "nic2",
	text3 = "nic3",
	
	text60 ="No DAta"
}




button.Triggered:Connect(function(Plr)

	local idk = Plr.Character
	local Quests = idk.QuestsStatus
	
	local name = Quests:GetAttribute("Name")
	local lvl = Quests:GetAttribute("Status")
	
	
	local Slowa = DialogsData[name..lvl]
	
	event:FireClient(Slowa)
	
end)

Local Script:


local label = script.Parent
local rs = game:GetService("ReplicatedStorage")
local TextEvent = rs.Remotes.RemoteDialogText

TextEvent.OnClientEvent:Connect(function(plr,Slowa)
	
	label.Text = Slowa
	
end)

when i print(“Slowa”) correct text will show up, but when I’m trying to send this by remoteEvent this happens:

obraz_2022-11-25_000223052

I have no idea what I’m doing wrong.

(this is my first post, sorry if I did something wrong.)

You have to send the Player you want to send the data to, then follow it up with any value:

event:FireClient(Plr, Slowa)
1 Like

Try

local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")

local button = script.Parent.ProximityPrompt
local event = rs.Remotes:WaitForChild('RemoteDialogText') 

local Quest = 60



local DialogsData = {


	nic0 = "nie ma questa w domu ",
	text2 = "nic2",
	text3 = "nic3",

	text60 ="No DAta"
}




button.Triggered:Connect(function(Plr)
	
	local player = players:FindFirstChild(Plr.Name)

	local idk = Plr.Character
	local Quests = idk.QuestsStatus

	local name = Quests:GetAttribute("Name")
	local lvl = Quests:GetAttribute("Status")


	local Slowa = DialogsData[name..lvl]
	
	if player then
	event:FireClient(player, Slowa)
end
end)
1 Like

obraz_2022-11-25_005509618

now i have problem inside localScript

local label = script.Parent
local rs = game:GetService("ReplicatedStorage")
local TextEvent = rs.Remotes.RemoteDialogText

TextEvent.OnClientEvent:Connect(function(plr,Slowa)
	
	label.Text = plr
	
end)

idk how this string get there but thanks :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.