Am I sending this text string to a remote event correctly?

So I have a script that basically gets the name of the player that hit an object:

script.Parent.Touched:Connect(function(hit) 
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	local Name = player.Name
game.ReplicatedStorage.Eliminated:FireServer(Name)
	
end)

The name then gets sent to a remote event that sends in which a script recieves that information:

game.ReplicatedStorage.Eliminated.OnServerEvent:Connect(function(eliminatedplayer)
	
	script.Parent.TextLabel.Text = eliminatedplayer
end)

However, none of this works as shown in the picture below:

How can I make the text display the player name?

1 Like

assuming that the event is fired(it looks correct to me), you need to change the above line to this

game.ReplicatedStorage.Eliminated.OnServerEvent:Connect(function(player, eliminatedplayer)--player is the user that sent the event

the first parameter would be the user that sent the event.

what do you mean? does it output a error? does nothing happen? can you please explain on how you know nothing works.

The error that prints out states:

what line is #3. ty for showing a picture of the error btw, most people just say invalid argument or something, and that doesn’t help very much.

edit: oh i got it, so above i told you to change

to

game.ReplicatedStorage.Eliminated.OnServerEvent:Connect(function(player, eliminatedplayer)

that shudl fix that error

It shows this error now:
image

Here is line 3:

1 Like

that means player is nil, make sure when you get player, you make sure what touched it is a character, so try something like this

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChildOfClass("Humanoid") then
        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        local Name = player.Name
        game.ReplicatedStorage.Eliminated:FireServer(Name)
    end
end)

This worked! Thank you! However, the outcome i had planned was not there.

The name displayed on the client-side fine:

But server-sided it just showed what i had before.

No errors however.

So my main question is: How do i make it change in the server-side aswell?

is the remove event still firing? to test you can do something like this,

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChildOfClass("Humanoid") then
        print("touched by a character")
        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        local Name = player.Name
        game.ReplicatedStorage.Eliminated:FireServer(Name)
    else
        print("something other than a character touched it")
    end
end)

I’m pretty sure it is firing as the text on the client-side screen has changed. But it doesn’t change on the server end.

image

Alright so i have an update:

I changed it so the script looked like this:
image

instead of this:
image

Now it shows up in server-side but not client side.

I solved it!

image

This made it so it was both client side and server side!

Thank you for the help Ocipa. The case is closed!