Can somebody explain why this remote event is not working?

Hello, I have this code in a local script;

game.ReplicatedStorage.GameHiearchy.RemoteEvents.client_DialogueEvent:FireServer(player, 3.5, "The phone began to ring.")

and here is my server script;

game.ReplicatedStorage.GameHiearchy.RemoteEvents.client_DialogueEvent.OnServerEvent:Connect(function(player, displayTime, message)
	print(player.Name)
	print(displayTime)
	print(message)
	dialogueConfig:Dialogue(player, displayTime, message)
end)

now what’s weird is this is my output;

ZombieKicker7
ZombieKicker7
3.5

why is this?

You don’t need to send the player as an argument as the FireServer function does that for you. As such:

-- Client
local Remote = game.ReplicatedStorage.GameHiearchy.RemoteEvents.client_DialogueEvent

Remote:FireServer(3.5, "The phone began to ring.")

-- Server
local Remote = game.ReplicatedStorage.GameHiearchy.RemoteEvents.client_DialogueEvent

Remote.OnServerEvent:Connect(function(player, displayTime, message)
	print(player.Name)
	print(displayTime) -> 3.5
	print(message) -> The phone began to ring.
	dialogueConfig:Dialogue(player, displayTime, message)
end)

Although I would still find the following code a better replacement for the server.

local Remote = game.ReplicatedStorage.GameHiearchy.RemoteEvents.client_DialogueEvent

Remote.OnServerEvent:Connect(dialogueConfig.Dialogue(dialogueConfig, player, displayTime, message)

I understand that but I actually want to send the player because I need it for the module script.

Like I said, the player is automatically passed as a parameter to the FireServer function.

@ZombieKicker7, take the following code as an example.

-- On the client:
RemoteEvent:FireServer('Sample_01') -- The Local Player is automatically passed as the first parameter to FireServer.

-- On the server:
RemoteEvent.OnServerEvent:Connect(function(Player, String)
    print(Player) -- LocalPlayer
    print(String) -> Sample_01
end)

Do not worry, just try out the code.

So to access the local player I would just use game.Players.LocalPlayer? Or how would I access the player object?

No, you can get it with the parameter of OnServerEvent as

RemoteEvent.OnServerEvent:Connect(function(player, displayTime, message)

But on the firing part you don’t need to pass the player:

RemoteEvent:FireServer(3.5, "The phone began to ring.")

1 Like

Thanks for the feedback! I just realised this and all is fixed now.