Code Issues - Client-Side Proximity Prompt is not working properly

Hello, I need a hand with the solution, please! :pray: The issue is that on the client side, I’m not getting the proximity prompt, and it’s showing the warn. What could be wrong?

  11:32:52.699  Invalid or nil ProximityPrompt received from server. Received: nil  -  Cliente - LocalScript:13

server script:

-- Server Script

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("showProxPrompt")

local elementProximityPrompt = script.Parent:WaitForChild("ProximityPrompt")

-- Print the value of elementProximityPrompt before sending it to clients
print("Initial elementProximityPrompt value:", elementProximityPrompt)

local function UpdatePlayersPromptVisibility()
	for _, player in pairs(Players:GetPlayers()) do
		if player.Team == Teams["Team 2"] then
			remoteEvent:FireClient(player, elementProximityPrompt, true)
		else
			remoteEvent:FireClient(player, elementProximityPrompt, false)
		end
	end
end

Players.PlayerAdded:Connect(function(player)
	UpdatePlayersPromptVisibility()
end)

localscript:

-- LocalScript

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("showProxPrompt")

remoteEvent.OnClientEvent:Connect(function(prompt, status)
	-- Check if the received prompt is a valid ProximityPrompt
	if prompt and prompt:IsA("ProximityPrompt") then
		-- Set the visibility of the ProximityPrompt based on the received status
		prompt.Enabled = status
		print("ProximityPrompt visibility set to " .. tostring(status))
	else
		-- Warn if an invalid or nil ProximityPrompt is received
		warn("Invalid or nil ProximityPrompt received from server. Received:", prompt)
	end
end)

Couldn’t you just put everything in a localscript? My guess is that youre sending an instance with the remote so it doesnt work

3 Likes

Hmm I hadn’t thought about it, I’m going to try it right now and let you know

1 Like

Hmm this is not possible and causes me more errors

1 Like