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

Speed onTouched leaderboard possible?

Before I start, I want to say that I know this isn't an ask and get service, but I don't know if this is possible in the first place.

Is it possible to detect a players speed, then input it into the leaderboard?

Say

local plr = -- I dunno...

script.Parent.Touched:connect(function(Touched)
	if game.Players:FindFirstChild(Touched.Parent.Name) ~= nil then
		local cash = stats:findFirstChild("Jump Distance")
		cash.Value  = plr.Character.Torso.Velocity.magnitude / 1.45

If this was possible, could someone come up with a script for this? That would be great.

  • Michael

1 comment

0

The WalkSpeed of a Humanoid...?

2 answers

✓ Accepted answer

To add on to coltn5000's code:

game.Players.PlayerAdded:connect(function(Player)
    local ls = Instance.new("IntValue", Player) -- create the leaderstats
    ls.Name = "leaderstats"
    local Speed = Instance.new("IntValue", ls) -- create (INT) Speed
    Speed.Name = "Speed"
    Player.CharacterAdded:connect(function(Character)
	wait()
        Character:WaitForChild("Torso").Changed:connect(function()
            Speed.Value = Character.Torso.Velocity.X>0 and Character.Torso.Velocity.X or Character.Torso.Velocity.Z ---i'm not sure if this is the best way to get the speed of that character, but that's the way I do it.
        end)
    end)
end)

1 comment

0

I'll probably be using this code. Thanks!

Yes it is possible to get a players speed then input to the leaderboard

Code:

game.Players.PlayerAdded:connect(function(Player)
	local ls = Instance.new("IntValue", Player) -- create the leaderstats
	ls.Name = "leaderstats"
	local Speed = Instance.new("IntValue", ls) -- create (INT) Speed
	Speed.Name = "Speed"
	Player.CharacterAdded:connect(function(Character)
		Character.Humanoid.Changed:connect(function()
			Speed.Value = Character.Humanoid.WalkSpeed -- Players Walk Speed
		end)
	end)
end)

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