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

Can somebody explain sending data through remote events?

Asked by 4 years ago

So i'm trying to learn how remote events work and i'm seeing that you can send data, I'm having trouble with this,

This is my local script, in StarterPack

01local usi = game:GetService("UserInputService")
02usi.InputBegan:Connect(function(imput, typing)
03    if typing then
04        return
05    else
06        if imput.KeyCode == Enum.KeyCode.F then
07            local x = game.ReplicatedStorage.RemoteEvent
08            x:FireServer(workspace.Baseplate.Color, game.Players.LocalPlayer.Name)
09        end
10    end
11 
12end)

When you press F the local script executes a remoteevent serversided.

This is my server script

1local event = game.ReplicatedStorage.RemoteEvent
2event.OnServerEvent:Connect(function(basecolor, plrname)
3    print(basecolor)
4    print(plrname)
5end)

When i press F, it prints 2 sets of information, But not what i want, first it prints my characters name(Entity_246) then coordinates (0.388235, 0.372549, 0.384314), What am i missing? are these values preset by Roblox and they have to be preset, or can i customize them?

Thanks for any help :)

1 answer

Log in to vote
1
Answered by
iHavoc101 127
4 years ago

Ah yes.

Roblox by default includes the argument of the player as the first one.

1local event = game.ReplicatedStorage.RemoteEvent
2event.OnServerEvent:Connect(function(Player, basecolor, plrname)
3    print(basecolor)
4    print(plrname)
5end)

That will work, you must specify player argument even if you don't use it

0
Thank you, :) EllaTheFloofyFox 106 — 4y
0
np :3 iHavoc101 127 — 4y
Ad

Answer this question