✓ Accepted answer
Hey there, Valiux!
The first thing to consider is that server scripts really should not run on the client. It's bad practice, and will not work correctly (if at all) under many circumstances. The client and server should never be intertwined, though that's a subject for another day. Let's jump into the solution:
We will make two scripts. One local script to change the GUI's text, and another server script to tell the local script when to do so. For the sake of cleanliness, I'm going to make another special type of script, called a Module, to store the admins. Observe:
The module, named Admins
return
{
["36872500"] = true;
};
The server script
local Admins = require(game.ServerStorage:WaitForChild("Admins"));
local OnChatted = Instance.new("RemoteEvent", game.ReplicatedStorage);
local GroupService = game:GetService("GroupService");
OnChatted.Name = "OnChatted";
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
if (string.sub(message, 1, 6) == "!raid " and Admins[player.UserId]) then
local groupID = string.sub(message, 7);
local group = GroupService:GetGroupInfoAsync(groupID);
OnChatted:FireClient(player, group.Name);
end;
end);
end);
And finally, the client:
local OnChatted = game.ReplicatedStorage:WaitForChild("OnChatted");
OnChatted.OnClientEvent:connect(function(groupName)
local text = "Raid Status: Official - " .. groupName;
for i = 1, #text do
script.Parent.rs.Text = string.sub(text, 1, i);
wait(0.1);
end;
end);
All right! I think I got everything. Give this solution a try, and let me know how it works for you. If there are any mistakes I made, do let me know. Have a nice day, Valiux, and best of luck with your game!
Warm regards,
tkcmdr
3 comments
If it's a studio test, your name is Player1 rather than Valiux. Other than who knows. Try using breakpoints.
You shouldn't have server scripts in StarterGui/PlayerGui. Use ServerScriptService.
you want a server side script to play inside of the client?