Incorrect RemoteEvent arguments

My goal is to send arguments player and item to the local script, but when I try to catch them, I get an error saying that the argument is not valid:
PlayerGui is not a valid member of Part “Workspace.BlockClone”

Server Script:

	if prompt.ActionText == "Inspect" then
		prompt.Enabled = false
		inspect:FireClient(player, item) -- inspect is the RemoteEvent

Client Script:

local gui = script.Parent

inspect.OnClientEvent:Connect(function(player, item)
	local clone = gui:Clone()
	clone.Enabled = true
	clone.Parent = player.PlayerGui

I’m pretty sure that the Triggered event returns the player, so I’m confused

1 Like

I tried making a local function instead:

local gui = script.Parent

local function event(player, item)
	local clone = gui:Clone()
	clone.Enabled = true
	clone.Parent = player.PlayerGui


Still doesn’t work

Try add some print statements like:


At first glance, nothing seems wrong.

When I try
I get:
attempt to index nil with “Name”

My item here is
local item = prompt.Parent which is a Part

Can you show me all the variables that you have in the script?

There is no Player argument in client remote events, but rather use the LocalPlayer to find them.

Server variables:

local inspect = game:GetService("ReplicatedStorage").Remotes.InspectItem
local prompt = script.Parent
local item = prompt.Parent

Client variables:

local replicatedStorage = game:GetService("ReplicatedStorage")
local inspect = replicatedStorage.Remotes.InspectItem
local gui = script.Parent

But I specifically need the player who triggered the ProximityPrompt, so how would that work?

And so in the client script do

local player = game.Players.LocalPlayer

And remove the player augment in the client for the client event for the player

Thank you that worked 30charrrrrr

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.