Hello! I need your help with scripting a time overhead that matches with my leader stats and a 10X time zone which gives 10 times the time
You would just make a billboard UI and within the UI Instance, you can just Connect to the leader board stats with Instance | Roblox Creator Documentation or NumberValue | Roblox Creator Documentation to detect whether the value changed or not.
within the function you would just set the value
TimeVal:GetPropertyChangedSignal("Value"):Connect(function()
TimeVal.Value
end)
Strictly an example
I don’t understand
Well did you insert a script
- you will make the billboard UI, Text label
- then you will insert a local script that will update the text value
- you wanna add the billboard into player head while they spawn
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
-- add Clone() builbaord / Parent = Character.Head
end)
end)
Resocures
I did the ui and text label, where do I add the local script? StarterPlayerScripts?
also where do I add the billboard ui? serverstorage?
You can place it Server Storage,Replicated Storage anywhere u prefer
You can add the local script in starter PlayerScripters indexing to the UI wouldn’t be as easy as Just placing the localscript within the textlabel.
Um, It didn’t work when I tested it
Do you know what exactly didn’t work?
can you explain what u did so far
I put billboard ui in serverstorage and LocalScript in ScriptPlayerService
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
-- add Clone() billboard/ Parent = Character.Head
end)
end)```
LocalScripts can’t access ServerStorage (hence, Server storage). Try putting it in ReplicatedStorage.
Alright, I’ll do it right now and I’ll test it out
This is the DataStore script in ServerScriptService:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
local function CreateStat(name, class, value, parent)
local stat = Instance.new(class)
stat.Name = name
stat.Value = value
stat.Parent = parent
return stat
end
local function GetKey(player)
return player.UserId .. "-"
end
local function SaveData(player)
local key = GetKey(player)
local leaderstats = player.leaderstats
local timeAliveData = leaderstats["Time Alive"].Value
local bestTimeData = leaderstats["Best Time"].Value
local success, result = pcall(function()
DataStore:SetAsync(key .. "TimeAlive", timeAliveData)
DataStore:SetAsync(key .. "BestTime", bestTimeData)
end)
if not success then
warn(result)
end
end
game.Players.PlayerAdded:Connect(function(player)
local key = GetKey(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local timeAlive = CreateStat("Time Alive", "IntValue", 0, leaderstats)
local bestTime = CreateStat("Best Time", "IntValue", 0, leaderstats)
local timeAliveData, bestTimeData
local success, result = pcall(function()
timeAliveData = DataStore:GetAsync(key .. "TimeAlive")
bestTimeData = DataStore:GetAsync(key .. "BestTime")
end)
if success then
timeAlive.Value = timeAliveData or 0
bestTime.Value = bestTimeData or 0
else
warn(result)
player:Kick("Error occured while retrieving your saved data.")
end
end)
game.Players.PlayerRemoving:Connect(SaveData)
if not RunService:IsStudio() then
game:BindToClose(function()
if #game.Players:GetPlayers() <= 1 then return end
for _, player in pairs(game.Players:GetPlayers()) do
SaveData(player)
end
end)
end```
Dukzae just wanted to help i get that but…
- The placement of the localscript was fine u don’t need it work rn
you haven’t edited the example code i sent and local script needa the billboardUI + local script
all the code i sent was an example something to possible start off on not to. copy and paste
and TimeScript in StarterCharacterScripts:
local humanoid = character.Humanoid
local player = game.Players:GetPlayerFromCharacter(character)
local leaderstats = player.leaderstats
local timeAlive = leaderstats["Time Alive"]
local bestTime = leaderstats["Best Time"]
local regionPart = workspace.Region
local min = regionPart.Position - (0.5 * regionPart.Size)
local max = regionPart.Position + (0.5 * regionPart.Size)
local region = Region3.new(min, max)
local function CheckSpawnRegion()
local objects = workspace:FindPartsInRegion3WithWhiteList(region, {character})
if #objects > 0 then
if not character:FindFirstChildOfClass("ForceField") then
local forceField = Instance.new("ForceField")
forceField.Visible = true
forceField.Parent = character
end
return true
else
local forceField = character:FindFirstChildOfClass("ForceField")
if forceField then
forceField:Destroy()
end
return false
end
end
local hasDied = false
humanoid.Died:Connect(function()
hasDied = true
end)
while wait() do
if hasDied then break end
while not hasDied and not CheckSpawnRegion() do
timeAlive.Value += 1
if timeAlive.Value > bestTime.Value then
bestTime.Value = timeAlive.Value
end
wait(1)
end
if hasDied then
timeAlive.Value = 0
end
end```
you wont need to interact with any of that why did you paste it
also you said it didnt work can i see the code your using? is there completed billboard code your using and testing?
Disable the localscript you will enable it once you place the billboardUI into Character.Head