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

Can somebody explain sending data through remote events?

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

✓ Accepted answer

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

2 comments

0

Thank you, :)

0

np :3

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