I tried to pass information from the client to the server, but it didn't work. I tried remote events, bindable events, remote functions, bindable functions, but none of them worked. Can someone help me? here is my code for client: `mouse.KeyDown:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer(brickcolor.new("Really Red") server code: game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(color) workspace.Part.BrickColor = color
✓ ANSWER ACCEPTED
How do you pass information in scripts though remote events?
1 answer
✓ Accepted answer
The KeyDown function is deprecated, It's better to use UserInputService instead
https://developer.roblox.com/en-us/api-reference/class/UserInputService
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(key)
if key.UserInputType == Enum.UserInputType.MouseButton1 then
game.ReplicatedStorage.RemoteEvent:FireServer(BrickColor.new("Really Red"))
end
end)
then your server script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(color)
workspace.Part.BrickColor = color
end)
4 comments
1
What does 'deprecated' mean?
1
It means that it is no longer supported
1
Thanks Jazmin! But there is one thing you missed after I realized. The player parameter. I have seen this many times. The client automatically Passes the player parameter which is the player who fired the event. So I think I just wanted to let you know.
0
Thank you, so in the second script it would be "OnServerEvent:Connect(function(player,color)" ?
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
@Omq_ItzJazmin Isn't the parameter supposed to be input? I know how to use UserInputService, but I use the :GetMouse method, its more easier. But thanks for the help!
it can be input, but you can use other variables too like key or button
Comment under her answer so she can be notified. You can name parameters anything most people use input but I know some use key instead.
I also remebered; I can use ContextActionService, too.