Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Parcel = require(9428572121)
- local placeOwnerID = game.CreatorId -- Gets the Place/Group Owner ID
- local ownerType = game.CreatorType -- Gets the type of owner (User or Group)
- if Parcel:Whitelist("66f04a2e9e16e072651ae40f", "qeni590wrtn41hf2trmm9w4iht7q") then
- if ownerType == Enum.CreatorType.Group then
- warn("[RTS] License successfully active for group owner (Group ID: " .. placeOwnerID .. "). FlowMaster started.")
- else
- warn("[RTS] License successfully active for place owner (User ID: " .. placeOwnerID .. "). FlowMaster started.")
- end
- else
- if ownerType == Enum.CreatorType.Group then
- warn("[RTS] License not active for group owner (Group ID: " .. placeOwnerID .. "). FlowMaster deleted.")
- else
- warn("[RTS] License not active for place owner (User ID: " .. placeOwnerID .. "). FlowMaster deleted.")
- end
- game.workspace["FlowMaster V1"]:Destroy()
- end
- local debug = false
- game.ReplicatedStorage["RTS FlowMaster V1"].EstimatedTime.OnServerEvent:Connect(function(player, gate, esttime)
- local Settings = require(game.Workspace["FlowMaster V1"].Configuration)
- -- Check if the player's rank is sufficient
- if player:GetRankInGroup(Settings.ControllerConfig.GroupID) <= Settings.ControllerConfig.MinimumRank then
- player.PlayerGui.FlowMaster.Configuration.GateNum:Destroy()
- player.PlayerGui.FlowMaster.Configuration.Send:Destroy()
- player.PlayerGui.FlowMaster.Configuration.TextBox:Destroy()
- player.PlayerGui.FlowMaster.Configuration.LocalScript:Destroy()
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = "[REQUEST INVALID] You cannot attempt to change gate status with under the required rank!"
- wait(2)
- player:Kick("[RTS FlowMaster] You have been kicked for attempting to change gate status when under the required rank! If you think this was a mistake, please contact support or check settings of the configuration.")
- return
- end
- -- Validate that the gate is a plain number
- local isGateValid = tonumber(gate)
- local isEstTimeValid = tonumber(esttime)
- if not isGateValid and not isEstTimeValid then
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = "[INVALID REQUEST] Please enter a valid gate and estimated time number."
- wait(2)
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = ""
- return -- Exit if both values are invalid
- end
- if not isGateValid then
- if debug then
- warn("Invalid gate number (not a plain number):", gate)
- end
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = "[INVALID REQUEST] Please enter a valid number for the Gate."
- wait(2)
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = ""
- return -- Exit if the gate is not a valid number
- end
- if not isEstTimeValid then
- if debug then
- warn("Invalid estimated time number (not a plain number):", esttime)
- end
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = "[INVALID REQUEST] Please enter a valid number for the Estimated Time."
- wait(2)
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = ""
- return -- Exit if the estimated time is not a valid number
- end
- local gateModelsFolder = game.Workspace["FlowMaster V1"]
- -- Debug print helper function
- local function debugPrint(...)
- if debug then
- print(...)
- end
- end
- -- Debug warnings helper function
- local function debugWarn(...)
- if debug then
- warn(...)
- end
- end
- debugPrint("Starting search for Gate:", gate)
- debugPrint("Player:", player.Name, "Estimated Time:", esttime)
- -- Function to search models for Configuration script and validate GateNumber
- local function searchAndCheckGateNumber(gate)
- -- Ensure gateModelsFolder exists
- if not gateModelsFolder then
- debugWarn("Gate Models folder not found!")
- return
- end
- -- Loop through each model in the folder
- for _, gateModel in pairs(gateModelsFolder:GetChildren()) do
- if gateModel:IsA("Model") then
- debugPrint("Checking model:", gateModel.Name)
- -- Check if the model has a Configuration ModuleScript
- local configModule = gateModel:FindFirstChild("Configuration")
- if configModule then
- if configModule:IsA("ModuleScript") then
- debugPrint("Found Configuration script in", gateModel.Name)
- -- Require the Configuration ModuleScript to access its table values
- local success, config = pcall(function()
- return require(configModule)
- end)
- if success then
- debugPrint("Successfully loaded configuration for", gateModel.Name)
- -- Explicitly convert gate and GateConfig.GateNumber to numbers for comparison
- local gateNumberFromConfig = tonumber(config.GateConfig.GateNumber)
- local gateNumberToCheck = tonumber(gate)
- -- Check if the GateNumber matches the provided number
- if gateNumberFromConfig and gateNumberToCheck and gateNumberFromConfig == gateNumberToCheck then
- debugPrint("Gate number matched for model:", gateModel.Name)
- local currentTime = os.date("%H:%M") -- Format: HH:MM
- gateModel.StopandGo.Screen.SurfaceGui.Estimated.Text = esttime.." Minutes"
- gateModel.StopandGo.Screen.SurfaceGui.Username.Text = "Set by " .. player.Name .. " at " .. currentTime
- game.ReplicatedStorage["RTS FlowMaster V1"].GateUpdate:FireAllClients(config.GateConfig.GateName, esttime)
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = "[SUCCESS] You have successfully edited the targetted gate and it has been updated"
- wait(2)
- player.PlayerGui.FlowMaster.Configuration.Notice.Text = ""
- -- Perform actions with the model (like opening doors)
- else
- debugPrint("Gate number did not match. Expected:", gateNumberToCheck, "Found:", gateNumberFromConfig)
- end
- else
- debugWarn("Failed to load configuration for model:", gateModel.Name, "Error:", config)
- end
- else
- debugWarn("Configuration found but is not a ModuleScript in model:", gateModel.Name)
- end
- else
- debugWarn("No Configuration script found in model:", gateModel.Name)
- end
- else
- debugWarn("Child is not a model:", gateModel:GetFullName())
- end
- end
- end
- -- Execute search function with the provided gate number
- searchAndCheckGateNumber(gate)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement