yeaSimon
(simonas)
September 25, 2022, 8:55pm
#1
Hello! So I am making a sword fighting game and I am making a main menu. The menu works with CharacterAutoLoads turned off because I have a script for it. Though whenever I press the play button, the gui never disables itself. It just clones itself every time I press play.
StarterPlayerScripts LocalScript:
local player = game:GetService("Players").LocalPlayer
for _, gui in pairs(game.StarterGui:GetChildren()) do
local ui = gui:Clone()
ui.Parent = player.PlayerGui
end
GetGlobals
(Globals)
September 25, 2022, 8:56pm
#2
Then we would need to see the code that runs when the button is pressed.
OwlCodes
(Owl)
September 25, 2022, 8:58pm
#3
The Gui is already put into the PlayerGui. You do not have to clone it and put it into the PlayerGui.
yeaSimon
(simonas)
September 25, 2022, 8:59pm
#4
local play = script.Parent
local fade = play.Parent.Parent.Fade
play.MouseButton1Click:Connect(function(player)
fade.Parent.Main.Visible = false
game.Lighting.Blur.Enabled = false
game:GetService("ReplicatedStorage").RemoteEvent:FireServer(player)
wait(1)
fade.Parent.Enabled = false
end)
and here is the event script
local Event = game:GetService("ReplicatedStorage").RemoteEvent
Event.OnServerEvent:Connect(function(player)
player:LoadCharacter()
player.PlayerGui.MainMenu:Destroy()
end)
yeaSimon
(simonas)
September 25, 2022, 9:00pm
#5
Whenever you have CharacterAutoLoads off, I’m pretty sure you need to clone it into the player gui (that’s what I’ve seen on the devforum)
OwlCodes
(Owl)
September 25, 2022, 9:02pm
#6
Well, I think what happens is, you Destroy the old Ui, but the Character loads in and clones it?
Does your Ui has reset on spawn enabled?
1 Like
GetGlobals
(Globals)
September 25, 2022, 9:02pm
#7
You need to store the GUIs somewhere else.
Running LoadCharacter also automatically loads the GUIs from StarterGui.
yeaSimon
(simonas)
September 25, 2022, 9:02pm
#8
Yeah, would I need to disable it?
OwlCodes
(Owl)
September 25, 2022, 9:04pm
#9
Yeah, you can try that. I still think that the Gui is being made again after character is loaded… Hm, let me try something.
1 Like
yeaSimon
(simonas)
September 25, 2022, 9:04pm
#10
Disabling ResetOnSpawn works. Thank you!
OwlCodes
(Owl)
September 25, 2022, 9:05pm
#11
Oh, I believe the destroy never worked, because you cloned on the client and tried to destroy on server.
1 Like
yeaSimon
(simonas)
September 25, 2022, 9:05pm
#12
What message should I mark as a solution?
OwlCodes
(Owl)
September 25, 2022, 9:05pm
#13
You can mark this as the solution if you want.
1 Like
yeaSimon
(simonas)
September 25, 2022, 9:07pm
#14
Would I need to change anything with my scripts? Or can I just keep ResetOnSpawn turned off
OwlCodes
(Owl)
September 25, 2022, 9:08pm
#15
Should just be reset on spawn turned off. Let me know if you run into any more issues.
1 Like
yeaSimon
(simonas)
September 25, 2022, 9:10pm
#16
Alright gotcha. Thank you again!