Write a roblox script where if the player played the game on 10/7/2024 specifically.…
- User
Write a roblox script where if the player played the game on 10/7/2024 specifically. (for example) It would print ("Secret Activated.")
- Assistant
Write a roblox script where if the player played the game on 10/7/2024 specifically. (for example) It would print ("Secret Activated.")
Certainly! Below is a Roblox script that checks if a player joins the game on October 7, 2024. If they do, it prints "Secret Activated." in the server's output and sends a notification to the player.
Create a RemoteEvent:
ReplicatedStorage in the Explorer.RemoteEvent and name it SecretEvent.Server-Side Script:
ServerScriptService, add a new Script and paste the following code:-- Server-side Script (ServerScriptService)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SecretEvent = ReplicatedStorage:WaitForChild("SecretEvent")
game.Players.PlayerAdded:Connect(function(player)
-- Get the current UTC date
local currentDate = os.date("!*t") -- UTC time
local targetYear = 2024
local targetMonth = 10 -- October
local targetDay = 7 -- 7th
-- Check if the current date matches the target date
if currentDate.year == targetYear and currentDate.month == targetMonth and currentDate.day == targetDay then
print("Secret Activated.")
-- Fire the RemoteEvent to notify the player
SecretEvent:FireClient(player)
end
end)
StarterPlayer > StarterPlayerScripts, add a new LocalScript and paste the following code:-- Client-side Script (LocalScript in StarterPlayerScripts)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SecretEvent = ReplicatedStorage:WaitForChild("SecretEvent")
SecretEvent.OnClientEvent:Connect(function()
-- Send a notification to the player
game.StarterGui:SetCore("SendNotification", {
Title = "Secret Activated",
Text = "Congratulations! You found the secret!",
Duration = 5
})
end)
Server-Side Script:
PlayerAdded event, which fires when a player joins the game.os.date("!*t")."Secret Activated." in the server output and fires the SecretEvent to the specific player.Client-Side Script:
SecretEvent from the server.SetCore("SendNotification") to display a notification to the player with the title "Secret Activated".Time Zones:
os.date("!*t")) to have a consistent reference regardless of the server's physical location.os.date("*t").Security Considerations:
Customization:
targetYear, targetMonth, and targetDay variables to match the current date.-- Example for testing on October 1, 2023
local targetYear = 2023
local targetMonth = 10
local targetDay = 1
Remember to change the date back to the original target date after testing.
With this script in place, when a player joins your game on October 7, 2024, they will receive a special notification, and the message "Secret Activated." will be printed in the server's output console.
Not yet included in a published release.