How Do I Use This RemoteEvent Sorry im bad at it

To Trigger it

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlayersRemoteClient = ReplicatedStorage:WaitForChild("PlayersRemoteClient")

script.Parent.Touched:Connect(function(Hit)

local Humanoid = Hit.Parent:FindFirstChildWhichIsA('Humanoid')

if Humanoid then

PlayersRemoteClient:FireServer()

end

end)

For It to work


local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlayersRemoteClient = ReplicatedStorage:WaitForChild("PlayersRemoteClient")

local Part = game.Workspace.Part

PlayersRemoteClient.OnServerEvent:Connect(function(player)

Part:Destroy()

end)

script is in Local Script for to trigger the server script is in Normal Script.

Do you get any errors when you run this?

I could be wrong, but I assume those 2 codes require to be Scripts, since the first one utilises BasePart.Touched, whereas the other one, really just destroys a part.

However, once they become Scripts, you can’t call :FireServer() hence you’re not on the client (is in LocalScript) - so you’d clash them together, and it saves a lot of space.

If you’re using it for an experiment:

--LocalScript in TextBox
local rep = game:GetService("ReplicatedStorage") --obtaining service
local RemoteEvent = rep.YourRemoteEvent
local textbox = script.Parent

textbox.FocusLost:Connect(function(enterPressed) --if entered/clicked off
    if not enterPressed then return --return if clicked off
    RemoteEvent:FireServer(textbox.Text) --sending the RemoteEvent text
end)
--Script in ServerScriptService
local rep = game:GetService("ReplicatedStorage")
local RemoteEvent = rep.YourRemoteEvent

rep.OnServerEvent:Connect(function(plr, text) --(who fired it, what text was inputted)
    print(plr.Name.." wrote ["..text.."] in the TextBox!")
end)

I think I know what the problem is, is your local script parented to a part? Because if it is that is what is causing it to not work, local scripts won’t run in the workspace, they have to be put in StarterGUI or StarterPlayerScripts

There’s multiple problems with remote events, such as:
:black_small_square:︎If the player has a script executor they can exploit the remote event to benefit themselves
:black_small_square:︎Remote events can cause lag, and have a slight delay.

Just put the :Connect(function(Hit) in a server script, and to find the player, use game:GetPlayerFromCharacter(model).

Edit: also a single script is a lot easier to follow than multiple that connect using events.

Both scripts need to be a different type

If they are and you want it to be like that just put the onserverevent function inside the place your firing it, or use a bindable event.

@adamaniac was right and @Doqee I wish I can give you both solution But I can’t. Sorry. This helped me a lot with Remote Events do I do the same with Remotr functions?

Yes you’d need to do the same for remote functions since they work on the same premise except that they are used for two-way communication whereas remote events are used for one-way communication.