Basically I have a value stored which is utilized by a if statement however it’s not working.
Heres my script:
loginbutton.MouseButton1Click:Connect(function()
if rankbox == settings.ranks then
loginbutton.Text = "Logged in as a Supervisor"
wait(0.4)
loginframe.Visible = false
supervisor.Value = true
callsignbox = callsign
else
loginbutton.Text = "Logged in as a Officer"
wait(0.4)
loginframe.Visible = false
supervisor.Value = false
callsignbox = callsign
end
end)
Heres my module script:
local module = {
ranks = "Sergeant"
}
return module
Essentially what the script is meant to do is check if the textbox text = “Sergeant” which is stored in the module then carry out the function however it is not working.
--- Module Variables
local module = game:GetService("ReplicatedStorage").Settings
local settings = require(module)
--- Login Frame
local callsignbox = script.Parent.LoginFrame.MainFrame.CallsignBox.Text
local rankbox = script.Parent.LoginFrame.MainFrame.RankBox.Text
local loginbutton = script.Parent.LoginFrame.MainFrame.LoginButton
local pnc = script.Parent.Parent["Police National Computer"]
local loginframe = pnc.LoginFrame
local supervisor = pnc.LoginFrame.MainFrame["IsASupervisor?"]
local callsign = pnc.LoginFrame.MainFrame.CallSign.Value
loginbutton.MouseButton1Click:Connect(function()
if rankbox == settings.ranks then
loginbutton.Text = "Logged in as a Supervisor"
wait(0.4)
loginframe.Visible = false
supervisor.Value = true
callsignbox = callsign
else
loginbutton.Text = "Logged in as a Officer"
wait(0.4)
loginframe.Visible = false
supervisor.Value = false
callsignbox = callsign
end
end)
loginbutton.MouseButton1Click:Connect(function()
if rankbox == settings.rank1 then
loginbutton.Text = "Logged in as a Supervisor"
wait(0.4)
loginframe.Visible = false
supervisor.Value = true
callsignbox = callsign
else
loginbutton.Text = "Logged in as a Officer"
wait(0.4)
loginframe.Visible = false
supervisor.Value = false
callsignbox = callsign
end
end)
local module = {}
module.rank1 = "Sergeant"
return module
-- modulescript in game.ReplicatedStorage called Ranks
return {
"Private",
"Private First Class",
"Corporal",
"Specialist",
"Sergeant",
"Staff Sergeant",
}
local ranks = require(game.ReplicatedStorage.Ranks)
-- print all ranks
for i, rank in ipairs(ranks) do
print(i, rank)
end
local player = game.Players.LocalPlayer
local playerRank = player.Rank.Value -- intValue
-- print the local players rank
print(ranks[playerRank])