Remote events failed to open UI the second time

  1. What do I want to achieve?
    I want to make it so that it fires a remote event to the client once the player triggers the Proximity Prompt.
  2. What is the issue?
    It works the first time, the remote event was successfully fired and received, but when trying to trigger the proximity prompt a second time, it ceases to work.

VIDEO

3. What solutions have I tried so far?
Here’s some code

local prompt = script.Parent
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Remotes"):WaitForChild("Events")
local pie = events:WaitForChild("PlayerShopInteraction")
prompt.Triggered:Connect(function(plr)
	pie:FireClient(plr)
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local hum = chr:FindFirstChildWhichIsA("Humanoid")
	hum.WalkSpeed = 0
	hum.JumpPower = 0
	prompt.Enabled = false
	wait(10)
	prompt.Enabled = true
end)

and below is the client one:

local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Remotes"):WaitForChild("Events")
local pie = events:WaitForChild("PlayerShopInteraction")
pie.OnClientEvent:Connect(function(shopname, itemnum, Items, Prices, ID, Desc, Rarity)
-- These tables were defined but the part where it's defined were not shown.
	print("Received package from server to setup.")
	ui:WaitForChild("Background").Visible = false
    print("it works!")
	ui:WaitForChild("Background").Visible = true
	pie = events:WaitForChild("PlayerShopInteraction")
end)

However, the player’s speed & jump power were set to 0 after the prompt was triggered in both attempts (as I was unable to move) and the code ran without any exception, error, or warnings. It’s just that there was no output in the second attempt.

1 Like

Maybe it’s the "pie = events:WaitForChild(“PlayerShopInteraction”) that destroyes the code.

It doesn’t affect the code at all, even after removing it or before it was added.

Would you be able to but a file for it?

What do you mean by “but a file for it”?

A file which containts the parts of the problem. Just easier than recreating it, lol

I still don’t understand what you are trying to say there.

He has already provided the code, theres no need for a file?

True, but we don’t know the setup. What is the prompt under? Where is it located? What is the “ui” variable connected to?

If you have read the code and it’s variables you would have figured it out.

We cannot help 100% if we don’t know the entire setup for it.

The UI variable is connected to a ScreenGui. If that has errors the compiler will throw an exception, which I explained that there was not any of those.

The setup is litteraly in the variables? it’s not that hard to setup, I’ve already completed the setup in my roblox studio.

I got this to work as you wanted it to.

Classic Baseplate.rbxl (31.8 KB)

1 Like

Well I see your issue straight away, you’re firing the client without transmitting any data to the client from the server but on the client’s side your expecting to receive data for the following parameters.

shopname, itemnum, Items, Prices, ID, Desc, Rarity

The following code snippet includes comments which should give further incite into how RemoteEvent instances should be used.

pie:FireClient(player, ...) --additional arguments after the player instance (which specifies which client to fire) are transmitted to the fired client
pie.OnClientEvent:Connect(function(...) --parameters are received by the callback function connected to the event in order to handle the data (values) which have been sent by the server

In the server side, you are only transferring the player parameters to the client.

But in your client side, you have several values, of which all of them will be nil


The above code was added, but it still doesn’t function as intended.

Is there any sort of error the first time that the code runs, that could potentially be the reason of ur script not running once again?

No. The compiler did not throw an error, warning, or exception.

This might be my lack of knowledge, but I dont think its possible to transfer a table from the server to the client and vice versa.