(Relaying for the scripter again)
Alright so It’s probably a good idea to provide the full spaghetti code. At this point I’m thinking it may be easier to separate out the music into its own script but I’d have to figure out how to link it up with the player spawning in.
We paid a competent programmer a lot of Robux to clean up this code for another game, so if it would be helpful to see the un-spaghettified but still broken version that I haven’t messed with then we can send that also.
MiscScript:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local MenuMusic = game.ReplicatedStorage.Music:WaitForChild("MusicGroup"):WaitForChild("MenuMusic")
local debounce = false
local SaveModelEvent = game:GetService("ReplicatedStorage").Events:WaitForChild("SaveModelEvent")
local ChangeStateEvent = game.ReplicatedStorage.Events:WaitForChild("ChangeStateEvent")
local KillPlayerEvent = game.ReplicatedStorage.Events.KillPlayerEvent
local ToEditorEvent = player:WaitForChild("ToEditorEvent", 30)
local KillEvent = player:WaitForChild("KillEvent", 30)
MenuMusic.Volume = 0.5
MenuMusic:Play()
player.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").Died:Connect(function()
game.ReplicatedStorage.Events.KillPlayerEvent:FireServer()
end)
--death by void
char.ChildRemoved:Connect(function()
if not char:FindFirstChild("HumanoidRootPart") and not debounce then
debounce = true
char.Humanoid.Health = 0
wait(1)
debounce = false
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if char:WaitForChild("Head"):WaitForChild("OverheadDisplay", 20) then
if player:FindFirstChild("HideBiosValue") and player.HideBiosValue.Value == true then
char.Head.OverheadDisplay.Content.DescLabel.Visible = false
char.Head.OverheadDisplay.Content.Position = UDim2.new(0, 0, 0.4, 0)
end
if player:FindFirstChild("HidePanelsValue") and player.HidePanelsValue.Value == true then
char.Head.OverheadDisplay.Enabled = false
end
end
end)
end)
--Add and prepare ClickDetectors when getting in the editor + various stuff
ToEditorEvent.Event:Connect(function()
local playerModel = workspace.Util.PlayerModels:WaitForChild(player.Name.."'s model")
local SelectedPart = player.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("CustomizationFrame"):WaitForChild("LeftPanel"):WaitForChild("SelectedPart")
local ColoringMode = player.PlayerGui.ScreenGui.CustomizationFrame.LeftPanel:WaitForChild("ColoringMode")
workspace.CurrentCamera.CFrame = workspace.Util.EditorCameraPart.CFrame
workspace.CurrentCamera.CameraType = Enum.CameraType.Follow
workspace.CurrentCamera.CameraSubject = playerModel:WaitForChild("HumanoidRootPart")
game:GetService("Lighting").Blur.Size = 0
player.CameraMaxZoomDistance = 35
player.CameraMinZoomDistance = 20
player.CameraMinZoomDistance = 5
ChangeStateEvent:FireServer("Editing")
mouse.TargetFilter = playerModel.HumanoidRootPart
mouse.Button1Down:Connect(function()
if ColoringMode.Value == "Advanced" and mouse.Target.Parent == playerModel then
SelectedPart.Value = mouse.Target
end
end)
end)
KillEvent.Event:Connect(function()
KillPlayerEvent:FireServer()
end)
CharacterAddedScript:
local player = game:GetService("Players").LocalPlayer
local playerGUI = player.LocalPlayer:WaitForChild("PlayerGui")
local camera = workspace.CurrentCamera
local Blur = game:GetService("Lighting").Blur
Blur.Size = 16
local TopBarBGF = game:GetService("ReplicatedFirst"):WaitForChild("TopBarBackgroundFrame")
local MenuMusic = game.ReplicatedStorage.Music:WaitForChild("MusicGroup"):WaitForChild("MenuMusic")
local GameMusic = game.ReplicatedStorage.Music:WaitForChild("MusicGroup"):WaitForChild("GameMusic")
local dens = workspace.Dens:GetChildren()
local ChangeStateEvent = game.ReplicatedStorage.Events:WaitForChild("ChangeStateEvent")
local KillEvent = player.LocalPlayer:WaitForChild("KillEvent", 30)
local CurrentState = player.LocalPlayer:WaitForChild("CurrentStateValue", 30)
local function ToggleCore(CoreElement, state)
local success = false
while not success do
success = pcall(function()
game:GetService("StarterGui"):SetCore(CoreElement, state)
end)
if success then
break
else
print("CoreGUI being slow for ", CoreElement)
wait(.1)
end
end
end
player.LocalPlayer.CharacterAdded:Connect(function(char)
TopBarBGF:Clone().Parent = playerGUI:WaitForChild("ScreenGui") --a frame to make the top bar with the menus green
local IsSpawningValue = player.LocalPlayer:FindFirstChild("IsSpawningValue") --a boolean saying if the player is going to spawn as the model (true) or goint to the main menu (false)
char:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
char.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false) --2 lines to prevent tripping and falling
if IsSpawningValue and IsSpawningValue.Value == true then
IsSpawningValue.Value = false
playerGUI.ScreenGui.GameInterfaceFrame.Visible = true
Blur.Size = 0
ChangeStateEvent:FireServer("Playing")
repeat wait()
camera.CameraType = Enum.CameraType.Custom
until camera.CameraType == Enum.CameraType.Custom
for i = 1, #dens do
if dens[i].OwnerName.Value == player.LocalPlayer.Name then
playerGUI.ScreenGui.GameInterfaceFrame.DenCommandFrame.DoorButton.Active = true
playerGUI.ScreenGui.GameInterfaceFrame.DenCommandFrame.LeaveButton.Active = true
playerGUI.ScreenGui.GameInterfaceFrame.DenCommandFrame:TweenPosition(UDim2.new(1, -203, 1, -103), "Out", "Quad", 1, true)
break
end
end
--stop music, keep at the end
local T = tick()
local t = 0
while t < 2 do
MenuMusic.Volume = (1 - t/2)*0.3
t = tick() - T
wait()
end
MenuMusic:Stop()
GameMusic.Volume = 0.3
GameMusic:Play()
else
Blur.Size = 16
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.Util:WaitForChild("MenuCameraPart").CFrame
ChangeStateEvent:FireServer("Main menu")
playerGUI.ScreenGui.CustomizationFrame.Visible = false
playerGUI.ScreenGui.GameInterfaceFrame.Visible = false
playerGUI.ScreenGui.ModelSelectFrame.AgeSelectFrame.AgeSelectScript.Disabled = false
playerGUI.ScreenGui.ModelSelectFrame.AgeSelectFrame.BackButton.BackScript.Disabled = false
playerGUI.ScreenGui.ModelSelectFrame.SpeciesSelectFrame.SpeciesSelectScript.Disabled = false
playerGUI.ScreenGui.ModelSelectFrame.SpeciesSelectFrame.Position = UDim2.new(0, 0, 0, 0)
playerGUI.ScreenGui.ModelSelectFrame.SpeciesSelectFrame.Visible = true
playerGUI.ScreenGui.ModelSelectFrame.LoadFrame.Visible = false
playerGUI.ScreenGui.ModelSelectFrame.AgeSelectFrame.Position = UDim2.new(0, 0, 1, 0)
playerGUI.ScreenGui.ModelSelectFrame.Visible = true
ToggleCore("ResetButtonCallback", false)
ToggleCore("TopbarEnabled", false)
if GameMusic.IsPlaying then
local T = tick()
local t = 0
while t < 2 do
GameMusic.Volume = (1 - t/2)*0.3
t = tick() - T
wait()
end
GameMusic:Stop()
end
end
end)
--support for player deep freeze
local IsFrozen = player.LocalPlayer:WaitForChild("IsFrozenValue", 30)
IsFrozen.Changed:Connect(function(newVal)
if newVal == true then
ToggleCore("ResetButtonCallback", false)
else
ToggleCore("ResetButtonCallback", KillEvent)
end
end)