The UI wouldn't popup after tweening

Hello, guys!

I’m currently working on the command for workers where they can use the command “notepad”, it will tween the UI to their screen. There is no error in the output. The script seems working fine, but the problem is I can’t see the UI. FYI, the visible of the UI is ENABLED.

local M = game:GetService("StarterGui").SwirlyzNotepad.Notepad

local Admins = {
	"cory";
	"Player1";
}

function tableContains(t, value)
	for _, v in pairs(t) do
		if v == value then
			return true
		end
	end
	return false
end

function onChatted(message, player)
	if message == "notepad" and tableContains(Admins, player.Name) then
		wait(1)
		M:TweenPosition(UDim2.new(0.527, 0, 0.611, 0), 'In', 'Quint', 1)
		wait(1)
	end
end

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(message)
		onChatted(message, player)
	end)
end)
1 Like

The issue here is that you’re editing the GUI in the StarterGui, this won’t update it dynamically across all clients unless they respawn, and it isn’t recommended to do it this way in general.

Instead, I’d recommend defining a OnClientEvent on a remote event client-sided, then when you desire to update that UI for players, instead of changing the StarterGui’s UI, call :FireAllClients on your remote event from the server to all the clients, and from there you can do whatever you want from inside your OnClientEvent event in the client.

Hope this helps, can give clarifications if needed. :slight_smile:

3 Likes

Oh, I thought I didn’t have to use FireEvents. Thank you for your response. I’m testing it now, I’ll let you know if it works or not.

1 Like
--Script
local RemoteEvents = game:GetService("ReplicatedStorage"):WaitForChild("Events")
local Notepad = RemoteEvents:WaitForChild("Notepad")

local Admins = {
	"cory";
	"Player1";
}

function tableContains(t, value)
	for _, v in pairs(t) do
		if v == value then
			return true
		end
	end
	return false
end

function onChatted(message, player)
	if message == "notepad" and tableContains(Admins, player.Name) then
		Notepad:FireClient()
	end
end

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(message)
		onChatted(message, player)
	end)
end)

----

--Localscript
local M = game:GetService("StarterGui").SwirlyzNotepad.Notepad
local RemoteEvents = game:GetService("ReplicatedStorage"):WaitForChild("Events")
local Notepad = RemoteEvents:WaitForChild("Notepad")

function Notepadfired()
	M:TweenPosition(UDim2.new(0.527, 0, 0.611, 0), 'In', 'Quint', 1)
end

Notepad.OnClientEvent:connect(Notepadfired)

It wouldn’t work, did I do something wrong?

I think you want to use:

:FireAllClients()

Sorry for not explaining clearly. I want to fire the server to a single client.

UPDATE: I tried using :FireAllClients() It wouldn’t work still…

Not sure if this will work, but


you need to define the player into the Fireclient Event
So Notepad:FireClient(player)
see if that works

2 Likes

In that case, it looks like you forgot to input the player as a parameter:

Notepad:FireClient(player)
2 Likes

Finally it works! Thank you both, for helping me. Appreciate it.
@EndurableRayy
@C_Sharper

2 Likes