Hello Devs,
I have this special script that when you creating a game it clones a gui and it is visible to all players but i have this issue where it clones more than one Ui and it is not visible to all players in the game I need help to fix this issue and code. Below is the video and the code.
in serverscriptservice
local CreateGameRemotes = game.ReplicatedStorage.CreateGameRemotes
local JGR = game.ReplicatedStorage.JoinGameRemotes
local CreateGame = CreateGameRemotes.CreateGame
local Theme = CreateGameRemotes.ThemeEvent
local PlrCount = CreateGameRemotes.NoPlrs
local Duration = CreateGameRemotes.DurationEvent
local Template = script.Parent
local Plrs = {}
CreateGame.OnServerEvent:Connect(function(plr, theme, totalplrs)
local TempClone = Template:Clone()
TempClone.Name = plr.Name
table.insert(Plrs, plr)
TempClone.PlayerName.Text = plr.DisplayName.."'s Room"
TempClone.Theme.Text = theme
for _, player in pairs(game.Players:GetPlayers()) do
if TempClone.Parent ~= player.PlayerGui.TitleScreen.ServerGameList.Gamelist then
TempClone.Parent = player.PlayerGui.TitleScreen.ServerGameList.Gamelist
end
end
end)
in local script in starterGui the last create button
CreateGame.OnServerEvent:Connect(function(plr, theme, totalplrs)
local TempClone = Template:Clone()
TempClone.Name = plr.Name
table.insert(Plrs, plr)
TempClone.PlayerName.Text = plr.DisplayName.."'s Room"
TempClone.Theme.Text = theme
for _, player in pairs(game.Players:GetPlayers()) do
TempClone:Clone().Parent = player.PlayerGui.TitleScreen.ServerGameList.Gamelist
-- clones it into their player gui
end
end)
for i, v in pairs(Template:GetChildren()) do
if v:IsA("ViewportFrame") then -- change Viewportframe to whatever Frame ur using (i guess ur just using a frame)
v:Destroy()
end
end
CreateGame.OnServerEvent:Connect(function(plr, theme, totalplrs)
local TempClone = Template:Clone()
TempClone.Name = plr.Name
table.insert(Plrs, plr)
TempClone.PlayerName.Text = plr.DisplayName.."'s Room"
TempClone.Theme.Text = theme
for _, player in pairs(game.Players:GetPlayers()) do
if not player.PlayerGui.TitleScreen.ServerGamelist:FindFirstChild(plr.Name) then
TempClone:Clone().Parent = player.PlayerGui.TitleScreen.ServerGameList.Gamelist
end
end
end)
Redo whole script, you’ve done it in the wrong way. When you create the game, you should have this game inside of a table on the server and send a remote call to client to create the gui for it. But that’s not the most reliable way and there are many problems. I would make a data model inside of a ReplicatedStorage which represents all created games.
honestly, for all the year i’ve been scripting in roblox, i’ve putten a gui to player’s interface from server only once. it was when i was working with soft shutdown screens and loading screens