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

how to pass data from server to client through remote events?

I have these scripts that pass a players username from one client to the rest of the clients. when I try to pass an argument through a remote event, it doesn't work. Here are the scripts

-- script
game.Workspace.Room1.OnServerEvent:Connect(function(player)
	game.StarterGui.Rooms.Frame.Room1.Owner.Value = player.Name
	game.StarterGui.Room1:FireAllClients(player)
end)

. .

-- local script
local function OnClick()
	script.Parent.TakenBy.Text = ("Taken by "..(game.Players.LocalPlayer.Name).."!")
	script.Parent.Owner.Value = game.Players.LocalPlayer.Name
	game.Workspace.Room1:FireServer()
end

script.Parent.MouseButton1Click:Connect(OnClick)


game.StarterGui.Room1.OnClientEvent:Connect(function(plr)
-- below is the line the output error is talking about
	script.Parent.TakenBy.Text = ("Taken by "..(plr).."!")  
end)

the localscript is in startergui. When the remote event is fired, the output says LocalScript:11: attempt to concatenate local 'plr' (a userdata value). what does that mean? Btw I am a noob at scripting and I don't really understand arguments and parameters. I barely even know what im doing. If you need more information ask me.

3 comments

0

Try changing "Taken by "..(plr).."!" to "Taken by "..(plr.Name).."!"

0

Watch the language! Profanity is not permitted here. https://scriptinghelpers.org/help/community-guidelines

1 answer

✓ Accepted answer

You are passing the player, not the player's name.

game.StarterGui.Room1:FireAllClients(player.Name)

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