Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- +1 Walkspeed Every Second, Leaderboard, Display speed, Auto save.
- -- MADE BY the_main_asher ON DISCORD!
- -- Give credits when using.
- -- How to use:
- -- Put a script inside ServerScriptService and paste this script in and hit play.
- -- This will add a NumberValue to everybody with the name of their username adding +1 every second and this will also create the textlabel thats displaying how much speed u got
- local DataStoreService = game:GetService("DataStoreService")
- local playerDataStore = DataStoreService:GetDataStore("PlayerWalkspeedData")
- local Players = game:GetService("Players")
- local function loadWalkspeed(player)
- local success, data = pcall(function()
- return playerDataStore:GetAsync(tostring(player.UserId))
- end)
- if success and data then
- return data
- else
- return 0
- end
- end
- local function createScreenGui(parent)
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "ScreenGui"
- screenGui.Parent = parent
- return screenGui
- end
- local function createNumberLabel(parent)
- local numberLabel = Instance.new("TextLabel")
- numberLabel.Name = "DisplayTime"
- numberLabel.Size = UDim2.new(0, 200, 0, 50)
- numberLabel.Position = UDim2.new(0.5, -100, 0, 10)
- numberLabel.Text = ""
- numberLabel.Parent = parent
- numberLabel.BackgroundTransparency = 1
- numberLabel.TextScaled = true
- numberLabel.Font = Enum.Font.SourceSansBold
- return numberLabel
- end
- game.Players.PlayerAdded:Connect(function(player)
- local playerData = Instance.new("Model")
- playerData.Name = "PlayerData"
- playerData.Parent = player
- local walkSpeedValue = Instance.new("NumberValue")
- walkSpeedValue.Name = "Walkspeed"
- walkSpeedValue.Value = loadWalkspeed(player) or 0
- walkSpeedValue.Parent = playerData
- player.CharacterAdded:Connect(function(character)
- local humanoid = character:WaitForChild("Humanoid")
- local function updateSpeed()
- humanoid.WalkSpeed = walkSpeedValue.Value
- local playerGui = player:WaitForChild("PlayerGui")
- local screenGui = playerGui:FindFirstChild("ScreenGui") or createScreenGui(playerGui)
- local numberLabel = screenGui:FindFirstChild("DisplayTime") or createNumberLabel(screenGui)
- numberLabel.Text = "Walkspeed: " .. walkSpeedValue.Value
- end
- updateSpeed()
- walkSpeedValue.Changed:Connect(function()
- updateSpeed()
- end)
- while true do
- task.wait(1)
- walkSpeedValue.Value += 1
- end
- end)
- end)
- -- This will save everything to the textlabel and the walkspeed itself
- local DataStoreService = game:GetService("DataStoreService")
- local playerDataStore = DataStoreService:GetDataStore("PlayerWalkspeedData")
- local Players = game:GetService("Players")
- local function saveWalkspeed(player, value)
- pcall(function()
- playerDataStore:SetAsync(tostring(player.UserId), value)
- end)
- end
- game.Players.PlayerAdded:Connect(function(player)
- player.CharacterRemoving:Connect(function()
- local walkSpeedValue = player:WaitForChild("PlayerData"):WaitForChild("Walkspeed")
- saveWalkspeed(player, walkSpeedValue.Value)
- end)
- end)
- for _, player in ipairs(Players:GetPlayers()) do
- game.Players.PlayerAdded:Fire(player)
- end
- -- This will add a leaderboard and will save the walkspeed on the leaderboard
- local DataStoreService = game:GetService("DataStoreService")
- local playerDataStore = DataStoreService:GetDataStore("PlayerWalkspeedData")
- local Players = game:GetService("Players")
- local function saveWalkspeed(player, value)
- pcall(function()
- playerDataStore:SetAsync(tostring(player.UserId), value)
- end)
- end
- local function loadWalkspeed(player)
- local success, data = pcall(function()
- return playerDataStore:GetAsync(tostring(player.UserId))
- end)
- if success and data then
- return data
- else
- return 16
- end
- end
- local function updateLeaderboard(player, value)
- local leaderstats = player:FindFirstChild("leaderstats") or Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local walkspeedStat = leaderstats:FindFirstChild("Walkspeed") or Instance.new("IntValue")
- walkspeedStat.Name = "Walkspeed"
- walkspeedStat.Parent = leaderstats
- walkspeedStat.Value = value
- end
- game.Players.PlayerAdded:Connect(function(player)
- local walkSpeedValue = Instance.new("NumberValue")
- walkSpeedValue.Name = "Walkspeed"
- walkSpeedValue.Value = loadWalkspeed(player)
- walkSpeedValue.Parent = player
- updateLeaderboard(player, walkSpeedValue.Value)
- player.CharacterAdded:Connect(function(character)
- local humanoid = character:WaitForChild("Humanoid")
- humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
- walkSpeedValue.Value = humanoid.WalkSpeed
- updateLeaderboard(player, walkSpeedValue.Value)
- saveWalkspeed(player, walkSpeedValue.Value)
- end)
- end)
- player.CharacterRemoving:Connect(function()
- saveWalkspeed(player, walkSpeedValue.Value)
- walkSpeedValue:Destroy()
- end)
- end)
- for _, player in ipairs(Players:GetPlayers()) do
- game.Players.PlayerAdded:Fire(player)
- end
Advertisement
Add Comment
Please, Sign In to add comment