it only affects the screengui on the server not for the clients, please tell me how to fix thanks.
local TweenService = game:GetService("TweenService")
local GroupService = game:GetService("GroupService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GroupId = 33325443 -- Replace with your group ID
local RequiredRank = 200
local AnnouncementSystem = game.StarterGui.AnnouncementSystem
local Frame = AnnouncementSystem.AnnouncementFrame
local TextLabel = Frame.AnnouncementText
local startPosition = UDim2.new(0.337, 0, -0.4, 0)
local endPosition = UDim2.new(0.337, 0, 0.07, 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local tweens = {
TweenService:Create(Frame, tweenInfo, { Position = endPosition }),
TweenService:Create(Frame, tweenInfo, { Position = startPosition })
}
function ShowGui()
print("Showing GUI")
tweens[1]:Play() -- Play the tween from start to end position
end
function HideGui()
print("Hiding GUI")
tweens[2]:Play() -- Play the tween from end to start position
end
local function ShowAnnouncement(message)
print("Showing Announcement with message: " .. message)
TextLabel.Text = message
ShowGui()
wait(5)
HideGui()
end
game.Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game")
player.Chatted:Connect(function(message)
print(player.Name .. " said: " .. message)
if message:sub(1, 2) == ":a" then
if player:GetRankInGroup(GroupId) >= RequiredRank then
local announcementMessage = message:sub(4)
ShowAnnouncement(announcementMessage)
else
print(player.Name .. " does not have the required rank. Rank is: " .. tostring(player:GetRankInGroup(GroupId)))
end
end
end)
end)
-- Replicate the GUI change to all players when the RemoteEvent is fired
ReplicatedStorage.ReplicateGuiChange.OnServerEvent:Connect(function(player, show, announcementMessage)
local playerGui = player:FindFirstChildOfClass("PlayerGui")
if playerGui then
local playerAnnouncementSystem = playerGui.AnnouncementSystem
if playerAnnouncementSystem then
local playerFrame = playerAnnouncementSystem.AnnouncementFrame
if playerFrame then
print("Replicating GUI change")
-- Update the TextLabel directly
ShowAnnouncement(announcementMessage)
-- Then, if you want to show/hide the GUI, you can do so here
-- playerFrame.Visible = show
end
end
end
end)