Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Client Side GUI will only show up one time from a remote event?

Hi I am working on a tycoon and am trying to create a GUI that pops up for the user when they try to buy something with insufficient funds. The GUI will pop up the first time someone tries to buy something without enough money, but it does not pop up again. Could anyone help me troubleshoot this?

Here is my server side script:

function InsufficientFunds()
		local Insuff = Instance.new("RemoteEvent")
		Insuff.Parent = game.ReplicatedStorage
		Insuff.Name = "Insuff"
		Insuff:FireClient()
end

---- Some stuff here if he has enough money---- This part works
else
	Sound(v, Settings.Sounds.ErrorBuy)
	InsufficientFunds() --Calls my insufficientFunds function

client side:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
 
local player = Players.LocalPlayer
local Insuff = ReplicatedStorage:WaitForChild("Insuff")
local playerGui = player:WaitForChild("PlayerGui")
local shop = player.PlayerGui.Nope.Shop
local function InsufficientFunds()
	shop.Visible = true
	wait(5)
	shop.Visible = false
end
 
Insuff.OnClientEvent:Connect(InsufficientFunds())

1 comment

0

My GUI is also popping up for everyone in the game. What could be going on here?

1 answer

Greetings. The reason why it appears only one time, is that you are creating multiple remote events with the same time, each time the function InsufficientFunds is ran. Please avoid doing that. Creating manually an remote event called InsufficientFunds is enough.

The reason why it appears for everyone is that FireClient() requires at least one argument. First argument has to be the player. For example:

RemoteEvent:FireClient(game.Players.JakyeRU)

Here's your fixed script:

Server Script:

local RemoteEvent = Instance.new("RemoteEvent", game.ReplicatedStorage)

-- Your Buy Function Here

wait(5)
RemoteEvent:FireClient(game.Players.JakyeRU)

Local Script:

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

local Player = Players.LocalPlayer
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local PlayerGui = Player:WaitForChild("PlayerGui")
local Shop = PlayerGui.Nope.Shop

function InsufficientFunds()
	Shop.Visible = true
	wait(5)
	Shop.Visible = false
end

RemoteEvent.OnClientEvent:Connect(InsufficientFunds())

This discussion is preserved as it was. New answers, comments, and votes are closed.