I want to know how to transfer data through remote events. I’ve seen this in games before where they only have 1 remote event that handles many things by transferring data to the server.
I don’t know how to pick up the data on the server side, though. Any help?
local event = game.ReplicatedStorage.Event1
-- random script where it checks for a keybind
event:FireServer("ability", something else idk) -- this line here, how would I pick up "ability" on the server side and then do something if the event sends "ability" ?
In your case, that will be correct. The ability will be a string if you send it as “Ability”.
You can also send instances/objects as long as they exist on the server, client-created instances/objects will return nil if sent.
game.ReplicatedStorage.SetupEvents.GenderSelect.OnServerEvent:Connect(function(player, Female, Male)
if Male then
print("male")
elseif Female then
print("female")
end
end)
I think you can understand it the way I made it now.
local RemoteEvent = game:GetService('ReplicatedStorage').RemoteEvent
local function ServerEvent(Player, FemaleOrMale)
if (FemaleOrMale == 'Female') then
print("It's a female!")
elseif (FemaleOrMale == 'Male') then
print("It's a male!")
end
end
RemoteEvent.OnServerEvent:Connect(ServerEvent)