Remote Event Trouble

Hello people,

I need help trying to open a Gui using a proximity prompt and a Remote Event.

Whenever I trigger the proximity prompt it says that the argument must be a player object
Screenshot 2025-06-03 093956

I can’t find anything on the forums so if anyone can assist me in this matter that would be helpful

This is my Server Script that is connected to the Proximity Prompt:

local pp = script.Parent

local rs = game:GetService("ReplicatedStorage")
local REEvent = rs.Events.RemoteEvent

local Players = game:GetService("Players")
local player = Players.LocalPlayer

pp.Triggered:Connect(function()
	REEvent:FireClient(player)
end)

And this is my Local Script connected to StarterCharacterScripts:

local rs = game:GetService("ReplicatedStorage")
local PlayerService = game:GetService("Players")
local localPlayer = PlayerService.LocalPlayer

local event = rs.Events.RemoteEvent

event.OnClientEvent:Connect(function()
	localPlayer.PlayerGui.CardGameGui.Enabled = true
	task.wait(0.5)
end)

Thank you in advance,
NotUD

The server cannot access the property “LocalPlayer” because “LocalPlayer” on the server does not exist.

local player = Players.LocalPlayer

Proximity Prompts, when triggered, pass the player that triggered it like so:

pp.Triggered:Connect(function(player)

See ProximityPrompt | Documentation - Roblox Creator Hub for more examples

3 Likes

That code makes no sense.
Where are you gonna get player?
Server script is ran on server hence it doesn’t have any player
Did you meant:?


pp.Triggered:Connect(function(player):Player
	REEvent:FireClient(player)
end)

Hello, small correction:

There is no need to write “:Player”, nothing is being returned in this case. If you are wondering which way is correct:

pp.Triggered:Connect(function(player)
	REEvent:FireClient(player)
end)

There is also no need to annotate which type “player” is either, Roblox studio does that for you.

Take care.

1 Like

Proofs?
Show me deassembled code on native with annotation+without annotation and then i will belive you.

A proximity prompt cannot be triggered without a player, and when a player triggers it, Roblox returns the player object. If it doesn’t, that is an issue that should be reported. Therefore, there is no need to perform a type check on this argument, as it should always be of a single, expected class.

We could also ask for proof, have you ever seen a RBXScriptSignal or a Roblox API returning an argument other than the guaranteed and expected classtype as specified on the engine and documentation?

1 Like


As you can see, even if I did not define p as type “Player”, it is already predefined by the engine.

--!strict
local hi = ""

Is also a string but script analisis in runtime could say otherwise as far as i know so no your argument is not valid when speaking of AOT compilation part likely it needs further argumentation with disecting disasembled code

1 Like

I recommend you read the Luau documentation, this is out of the scope of OP’s discussion, and if you are still unsure after I explain it here, I invite you to create another post in Scripting Support.

Roblox has already made the type annotation to the things being sent through that Triggered Signal, there is no need to double annotate. Internally, the .Triggered signal has these predefined return types:

You cannot assign “p” anything other than Player, and it is already defined as “Player”, there is no reason to annotate that variable.

Here is the proof that there is no type errors, even when using --!strict: (Type errors show in orange)

And as you can see, even if I didn’t define “p” as “Player”, the method :Kick() still comes up, proving that there is no need to annotate this variable.

Scripting Support

i was talking about actual typechecking part as to how this example would behave in native mode and if assembly of 2 different examples would be the same;
Not about type anotations.

Hi, it’s common for beginners to use LocalPlayer in a Script, which is not possible. Fortunately, the player is passed as a parameter of the Triggered event (see docs), so you can just do this:

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage.Events.RemoteEvent

script.Parent.Triggered:Connect(function(player)
    event:FireClient(player)
end)

That is the fix to your issue. However, it is possible to use the Triggered event on the client aswell, so you can just merge your code into your LocalScript like this:

local players = game:GetService("Players")
local player = players.LocalPlayer

local playerGui = player:WaitForChild("PlayerGui")

local proximityPrompt = workspace.Part.ProximityPrompt -- Change this path to point to where your ProximityPrompt is

script.Parent.Triggered:Connect(function(player)
    playerGui.CardGameGui.Enabled = true
end)

Your gui should appear nicely when the ProximtyPrompt is triggered, but the code could be even better.

From the years I’ve been scripting, I never really had to enable or disable ScreenGuis directly. It would be better to change the Visible property of the objects inside.

Here is that same LocalScript code from above parented to the ScreenGui, which detects when the ProximityPrompt is triggered and makes a frame named “Frame” in the ScreenGui visible.

local proximityPrompt = workspace.Part.ProximityPrompt -- Change this path to point to where your ProximityPrompt is

script.Parent.Triggered:Connect(function(player)
    script.Parent.Frame.Visible = true
end)

Your explorer heirarchy should look like this, and the code above goes inside the LocalScript.
image

2 Likes