Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i get the walkspeed into leaderboard?

I've made a leaderboard with the name speed as im making a speed simulator, but i cant seem to get the local players speed value in there

    local dataStores = game:GetService("DataStoreService"):GetDataStore("Speed")

local deafaultSpeed = 0

local playerLeft = 0

  

game.Players.PlayerAdded:Connect(function(player)

playerLeft = playerLeft + 1

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

local speed = Instance.new("IntValue")

speed.Name = "Speed"

speed.Value = game.StarterGui.ScreenGui.speed.Text

speed.Parent = leaderstats

that is my struggle

1 comment

0

the only lua and roblox studio i learn is from youtube and other scripts that i read

3 answers

If you want the player's speed, it is simple you already have the joined player in a variable you could just get his character by

player.CharacterAdded:Wait()
local char = player.Character

then you have his/her WalkSpeed Value like this

local charSpeed = char:FindFirstChild("Humanoid").WalkSpeed
speed.Value = charSpeed

Hope this helped.

1 comment

0

didnt work

`im assuming u want the walkspeed to be able to go up by training or whatever right? well i made something similair today but with statpoints so first u want to make some variables and then make a intvalue for speed

local plr = game:GetService("Players").LocalPlayer -- getting the plr 
local char = plr.Character or plr.CharacterAdded:Wait() -- getting the char
local hum = char:WaitForChild("Humanoid") -- getting the humanoid never do WalkSpeed or any value in a variable !!!! 
local speed = instance.new("IntValue") -- making a intvalue	
speed.Name = "Speed" -- naming it Speed 
speed.Value = 16 -- setting the value to 16 btw 16 is default speed 
speed.Parent = leaderstats -- parenting it to leaderstats 
while wait() do -- to keep it updated
hum.WalkSpeed = speed -- btw never do WalkSpeed or any value in a variable or it will overwrite
end

i hope this will work for you ^^

1 comment

0

did not work at all:(

Hello! I'm BlackOrange3343 and I'll be helping you today.

There a few problems here, one being you are setting the speed value based on a text. Also another problem being you're doing StarterGui not PlayerGui

Difference Between StarterGui and PlayerGui StarterGui is somewhat similar to a storage. What happens is when the game runs and a player joins, everything in the StarterGui will be cloned and re parented to the PlayerGui. When you update the StarterGui, the next player who joins will see the changes. PlayerGui on the other hand is live. It is what's displayed to the Client. What you want to do is update elements with in the PlayerGui for the player to see live updates.

So:

  1. Insert a Script into ServerScriptService
  2. Create all the variables you'll need.
local Players = game:GetService('Players')
local PlayerCount = 0

Players.PlayerAdded:Connect(function(Player)
	PlayerCount = #Players:GetChildren() -- This is more accurate
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local PlayerGui = Player:WaitForChild('PlayerGui')
	
end)
  1. Now finish it off
local Players = game:GetService('Players')
local PlayerCount = 0

Players.PlayerAdded:Connect(function(Player)
	PlayerCount = #Players:GetChildren() -- This is more accurate
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local PlayerGui = Player:WaitForChild('PlayerGui')
	
    local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = Player
	local speed = Instance.new("IntValue")
	speed.Name = "Speed"
	speed.Value = PlayerGui.ScreenGui.speed.Text -- the change is PlayerGui
	speed.Parent = leaderstats
end)

If you want anything additional, you'll have to add it yourself. ScriptingHelpers is a place where we help developers script. We will not write full scripts for you. I've somewhat have but do not expect it to work. This is a raw script that I have simply edited from yours. If you do expect other functions then add them yourself.

Best of luck developer and hope this helped.

BlackOrange3343

PS: Learn the basics before making a game or failure will strike multiple times until the scripter gives up or actually restarts.

1 comment

0

im sorry but the edit u did only made it worse

This discussion is preserved as it was. New answers, comments, and votes are closed.