Hello, i want to make a application center and a loading script but they seem to not be working. I would be very happy if someone could provide a fix.
Application Center Bot Script:
local function chat(text)
game:GetService("Chat"):Chat(script.Parent, text)
end
local playerName = workspace:WaitForChild("playername").Value
task.wait(3)
chat("Hello, Welcome to Application Centre!")
task.wait(1.5)
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerData")
local success, err = pcall(function()
local player = game.Players:FindFirstChild(playerName)
if not player then
error("Player not found")
end
local userId = player.UserId
local data = datastore:GetAsync("Rank" .. userId)
local quiz = player.PlayerGui:WaitForChild("quiz"):WaitForChild("Frame"):WaitForChild("quizframe")
if data and data.Rank ~= nil then
if data.Rank ~= "0 Instance" then
chat("You will start a quiz that contains 10 questions")
chat("about the cafe and also attitude & behavior in the cafe.")
task.wait(5)
chat("We are going to start in..")
chat("5")
task.wait(1)
chat("4")
task.wait(1)
chat("3")
task.wait(1)
chat("2")
task.wait(1)
chat("1")
task.wait(1)
chat("The quiz just opened on your screen!")
player.PlayerGui.quiz.Enabled = true
local questions = {
q1 = "What studio made Drinkiez?",
q1a = "Gold Assassin Studios",
q1b = "Gold Dominus Studio",
q1c = "Gold Assassin Studios",
}
local question = 1
local function updateQuestion()
if questions["q"..question] then
quiz.question.Text = questions["q"..question]
quiz.a.Text = questions["q"..question.."a"]
quiz.b.Text = questions["q"..question.."b"]
end
end
updateQuestion()
local function checkAnswer(answer)
if answer == questions["q"..question.."c"] then
question = question + 1
if question == 2 then
datastore:SetAsync("Rank"..userId, 2, {userId})
player:Kick("Congratulations! You passed the quiz. You got ranked to Trainee!")
else
updateQuestion()
end
else
player:Kick("Wrong answer! Please re-attend the quiz.")
end
end
quiz.a.MouseButton1Click:Connect(function()
checkAnswer(quiz.a.Text)
end)
quiz.b.MouseButton1Click:Connect(function()
checkAnswer(quiz.b.Text)
end)
else
chat("It looks like you did the quiz before, now you need to attend trainings to get higher ranks!")
task.wait(1.5)
player:Kick("Visit training centre to get higher ranks!")
end
else
chat("Error: Rank data not found or invalid.")
end
end)
if not success then
chat("Error setting or retrieving data from datastore: " .. err)
end
Loading script main game:
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerData")
game:GetService("Players").PlayerAdded:Connect(function(plr)
local intv = Instance.new("IntValue")
intv.Name = "Rank"
intv.Value = 0
intv.Parent = plr
local intv2 = Instance.new("IntValue")
intv2.Name = "DrinkiezBucks"
intv2.Value = 1000
intv2.Parent = plr
local success, response = pcall(function()
local rankData = datastore:GetAsync("Rank" .. plr.UserId)
local bucksData = datastore:GetAsync("DrinkiezBucks" .. plr.UserId)
print("Rank data before gsub: ", rankData)
print("Bucks data before gsub: ", bucksData)
if rankData then
local rankString = string.gsub(rankData, "Instance", "")
print("Rank data after gsub: ", rankString)
local rankNumber = tonumber(rankString)
if rankNumber then
intv.Value = rankNumber
else
warn("Invalid rank number after conversion: ", rankString)
end
end
if bucksData then
local bucksString = string.gsub(bucksData, "Instance", "")
print("Bucks data after gsub: ", bucksString)
local bucksNumber = tonumber(bucksString)
if bucksNumber then
intv2.Value = bucksNumber
else
warn("Invalid bucks number after conversion: ", bucksString)
end
end
end)
if not success then
print("Error retrieving data: " .. response)
end
-- Set default values if data is not retrieved or is invalid
if intv.Value == 0 then
datastore:SetAsync("Rank" .. plr.UserId, "0 Instance")
end
if intv2.Value == 1000 then
datastore:SetAsync("DrinkiezBucks" .. plr.UserId, "1000 Instance")
end
if plr.Name == "Spilleparadiss" then
intv.Value = 12
end
if intv.Value ~= 0 then
local staffCard = game:GetService("ServerStorage"):WaitForChild("Staff Card"):Clone()
staffCard.Parent = plr:WaitForChild("Backpack")
end
end)
Logs:
21:09:29.966 Requiring asset 6330938629.
Callstack:
Workspace.DWProx - OfficeDoorDouble.Settings.Script, line 7
Workspace.DWProx - OfficeDoorDouble.Settings.Script, line 7
Workspace.DWProx - OfficeDoorDouble.Settings.Script, line 7
- Server - Script:7
21:09:29.967 Requiring asset 5918376498.
Callstack:
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.Loader, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.Loader, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.Loader, line 8
- Server - Loader:8
21:09:30.786 ShowcaseBaseplate - Server
21:09:30.786 PrototypeBaseplate - Server
21:09:30.786 2021 Baseplate - Server
21:09:30.786 Anime Baseplate - Server
21:09:30.787 [DWProx V3] HTTP Notice: Http Check Successful! - Server - DWPROXV3-HANDLER:8
21:09:30.836 Requiring asset 6036649147.
Callstack:
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
- Server - DWPROXV3-ENGINE:8
21:09:31.061 ShowcaseBaseplate - Client
21:09:31.061 PrototypeBaseplate - Client
21:09:31.061 2021 Baseplate - Client
21:09:31.061 Anime Baseplate - Client
21:09:31.071 Requiring asset 5588673109.
Callstack:
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
Workspace.DWProx - OfficeDoorDouble.DWProx.Settings.DWPROXV3-ENGINE, line 8
- Server - DWPROXV3-ENGINE:8
21:09:31.115 Rank data before gsub: 0 Instance - Server - playerload:17
21:09:31.115 Bucks data before gsub: 1000 Instance - Server - playerload:18
21:09:31.116 Rank data after gsub: 0 - Server - playerload:22
21:09:31.116 Bucks data after gsub: 1000 - Server - playerload:33
I also tried using a popular AI website you know, but he didnt help to much.