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 3 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

local usi = game:GetService("UserInputService")
usi.InputBegan:Connect(function(imput, typing)
    if typing then
        return
    else
        if imput.KeyCode == Enum.KeyCode.F then
            local x = game.ReplicatedStorage.RemoteEvent
            x:FireServer(workspace.Baseplate.Color, game.Players.LocalPlayer.Name)
        end
    end

end)

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

This is my server script

local event = game.ReplicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(basecolor, plrname)
    print(basecolor)
    print(plrname)
end)

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
3 years ago

Ah yes.

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

local event = game.ReplicatedStorage.RemoteEvent
event.OnServerEvent:Connect(function(Player, basecolor, plrname)
    print(basecolor)
    print(plrname)
end)

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

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

Answer this question