Script not changing text on a gui when ran a command

Using a admin system: Adonis Admin

I set it as a server plugin, and it’s nothing to do with adonis i’m 99% sure. So why is this textlabel not changing? Here’s the code:

--!nolint UnknownGlobal
--[[
	SERVER PLUGINS' NAMES MUST START WITH "Server:" OR "Server-"
	CLIENT PLUGINS' NAMES MUST START WITH "Client:" OR "Client-"

	Plugins have full access to the server/client tables and most variables.

	You can use the MakePluginEvent to use the script instead of setting up an event.
	PlayerChatted will get chats from the custom chat and nil players.
	PlayerJoined will fire after the player finishes initial loading
	CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.

	service.Events.PlayerChatted(function(plr, msg)
		print(msg..' from '..plr.Name..' Example Plugin')
	end)

	service.Events.PlayerJoined(function(p)
		print(p.Name..' Joined! Example Plugin')
	end)

	service.Events.CharacterAdded(function(p)
		server.RunCommand('name',plr.Name,'BobTest Example Plugin')
	end)

--]]
local Message = game.StarterGui.Coords.Frame.Text

return function()
	server.Commands.ExampleCommand = {
		Prefix = server.Settings.Prefix;	-- Prefix to use for command
		Commands = {"emergencybroadcast"};	-- Commands
		Args = {"message"};	-- Command arguments
		Description = "Sets a emergency broadcast.";	-- Command Description
		Hidden = false; -- Is it hidden from the command list?
		Fun = false;	-- Is it fun?
		AdminLevel = "Moderators";	    -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
		Function = function(plr,args)    -- Function to run for command
			Message.Text = args[1];
		end
	}
end

And here’s explorer:
image

You are changing the variable, not the text label’s text.
Oops, thought it was a TextLabel not a Frame. Indexing the frame with Text is legit.
Also, I noticed that you are changing the StarterGui elements. This won’t change as expected.

Maybe try using a remote event and OnClientEvent change your text and use FireAllClients

image
I renamed it to make it organized, but how am I changing the variable?

You were defining the local variable Message as a string (the text label 's text) by indexing the Text property.

I’m confused, how am I setting message as a string? I’m setting it just to find the textlabel but not to go inside the properties of the textlabel.

Here is an edited function to match your needs:

		Function = function(plr,args)    -- Function to run for command
			for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
				if not Player:FindFirstChildWhichIsA("PlayerGui") then continue end
				if not Player.PlayerGui:FindFirstChild("Coords") then continue end
				local TextLabel = Player.PlayerGui.Coords.BroadCast
				TextLabel.Text = args[1];
			end
		end

image

image


What did I mess up?

Forgot to edit the path here, this should be Player.PlayerGui.Coords.Frame.Broadcast

Wait let me try again, You put BroadCast instead of Broadcast.

Thank you so much! All fixed, completey works!

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