I’m working on a class selection GUI, I have the following code below, and whenever I get the notification once I click “yes” my studio just crashes. Everything prints, not too sure what’s going on. I have made a lot of edits to this code to try and get it to not crash, but simply just no luck, even if I go to just stop my playtest in studio, I crash. Help would be greatly appreciated.
P.S if there’s a possible way to incorporate my table of classes with whichever class is selected, please let me know how I can do so! Thank you for reading.
local plr = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local notiOS = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local clientToServ = ReplicatedStorage:WaitForChild("clientToServ")
local servToClient = ReplicatedStorage:WaitForChild("servToClient")
local modules = ReplicatedStorage:WaitForChild("modules")
local utilMod = require(modules:WaitForChild("LayoutUtil"))
local bg = script.Parent:WaitForChild("bg")
local holder = bg:WaitForChild("holder")
local notification = script.Parent:WaitForChild("notification")
local texts = notification:WaitForChild("texts")
local buttons = notification:WaitForChild("buttons")
local selected = "nil"
utilMod.new(holder:WaitForChild("UIGridLayout"))
local classes = {
"discoverer",
"scavenger",
"consciousness",
"survivalist"
--THINK OF ONE MORE
}
for _, classOption in pairs(holder:GetChildren()) do
if classOption:IsA("TextButton") then
classOption.MouseButton1Click:Connect(function()
if classOption.Selectable then
selected = classOption.Name
texts.class.Text = "<i><b>" .. string.upper(classOption.Name) .. "</b></i>"
notiOS = true
notification:TweenPosition(UDim2.new(0.5, 0, 0.5, 0),0.7)
elseif not classOption.Selectable then
local id = classOption:FindFirstChildOfClass("IntValue")
game.MarketplaceService:PromptGamePassPurchase(plr, id.Value)
end
end)
end
end
for _, option in pairs(buttons:GetChildren()) do
if option:IsA("TextButton") then
option.MouseButton1Click:Connect(function()
notification:TweenPosition(UDim2.new(0.5, 0, -0.5, 0),0.7)
notiOS = false
if option.Name == "yes" then
if selected ~= "nil" then
if selected == "discoverer" or selected == "scavenger" or selected == "consciousness" or selected == "survivalist" then--or selected == "discoverer" then
clientToServ:FireServer("selectClass", string.lower(texts.class.Text))
print("fired")
clientToServ:FireServer("deleteUI", "classSelection")
print("done")
end
end
end
end)
end
end