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

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

Asked by
Faazo 84
6 years ago
Edited by M39a9am3R 6 years ago

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.

0
Try changing "Taken by "..(plr).."!" to "Taken by "..(plr.Name).."!" trecept 367 — 6y
0
Watch the language! Profanity is not permitted here. https://scriptinghelpers.org/help/community-guidelines M39a9am3R 3210 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago

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

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

Answer this question