Help with RemoteEvent

I want to grasp a better understanding on RemoteEvents especially for this:
SERVER
https://gyazo.com/1574a92408b16e3a0ce0411a754422f1

CLIENT

local UserInputService = game:GetService("UserInputService")

local debounce = true
local distance = 4

local function key(inputy, typingx)
	if typingx then return end
	if inputy.KeyCode == Enum.KeyCode.E and (game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart").Position - game.Workspace.CrateStuff.start.Position).Magnitude <= distance then --requirements
		game.ReplicatedStorage.Crate:FireServer(69) --xD
	end
end

UserInputService.InputBegan:Connect(key)

I have tried to change it up with OnClientEvent and FireAllClients()

I am not asking for entire scripts, I am asking for help with the script I’ve provided above. I DO NOT want to be spoon-fed answers.

1 Like

The first parameter of OnServerEvent is player, so you would wanted to do (player, chances…)

Doesn’t that mean i’d have to :FireClient()
or is it :FireAllClients() to add in the tuple arg

The Connect method only accepts one parameter a function,if you need those other strings you have in the connect function you need to store them in variables, you need to do:

game.ReplicatedStorage.Crate.OnServerEvent:Connect(chances)

Also, you only pass one parameter from the client why do you have two?

FireAllClients is used to communicate with every player in the game, on their individual client. FireClient is used for just one client. I’m talking about when you do OnServerEvent, the first parameter is the player object, and then you can define your arguments.

he defines the player argument in the chances function the issue is how he writes the connection.

Yeah that’s what I’m referring to.

Demonstration of Client to Server RemoteEvent:


Client:

game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent"):FireServer("Hello")

Server:
(Keep in mind that firing remote event from client to server ALWAYS the first argument is player automatically)

game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent").OnServerEvent:Connect(function(player,hello)
    print(player.Name.." said "..hello)
    --do your function here
end)

are you referring to the

Local function key(inputy, typex)

test the solution i provided its correct

Alright, what i’ve read from dev hub. They said that FireAllClients can contain tuple args and fireclient has to have a player instance and args.

What im getting from here has no relation to what i’ve read up on.

I need deeper explanation
(30)

It’s not correct, it doesnt even work