WalkSpeed of humanoid prints as 22 when, on spawn, it is 9.5

I’ve been messing with my ParticleEmitter script that makes a trail off of the humanoidrootpart after the humanoid reaches 85 walkspeed, but it keeps printing as 22 no matter what I do, even after parenting it to the humanoid. YouTube definitely wouldn’t be able to help with this one.

task.wait(0.5) -- I will replace this as a function that starts when character is added
script.Parent = script.Parent.Humanoid -- Sets parent to humanoid
print(script.Parent.WalkSpeed) -- This prints as 22 no matter what

while true do task.wait()
	if script.Parent.WalkSpeed > 85 then
		script.Parent.Parent.HumanoidRootPart.ParticleEmitter.Enabled = true
		
	else
		script.Parent.Parent.HumanoidRootPart.ParticleEmitter.Enabled = false
		
	end
end

Don’t mind the infinite yield, I’m not planning to fix that.

The speed next to the overdrive meter is the true speed; so I’m confused as to why it prints “22” in a seperate one. The speed is math.floor(Humanoid.WalkSpeed)

When changing the speed like for an example

local walkspeed = script.Parent.WalkSpeed

That is getting the current walkspeed it’s was set

If you want to detect it updating you can update it aswell by doing in the loop-function like this

while true do task.wait()
    walkspeed = script.Parent.WalkSpeed -- this way it updates while during the loop so you don't always get the current one, I'm sure you can also do it many other ways but this one is an example.
	if script.Parent.WalkSpeed > 85 then
		script.Parent.Parent.HumanoidRootPart.ParticleEmitter.Enabled = true
		
	else
		script.Parent.Parent.HumanoidRootPart.ParticleEmitter.Enabled = false
		
	end
end

Correct me if this didn’t help.

Before I try this:

The humanoid walkspeed starts at 9.5 as I stated in the title.

Did not work. It continuously checks the walk speed anyway, so this is not the problem

image

Why did you put that when it continously printed the walkspeed? Seems unnecessary
Before I made the topic, it continously printed the walkspeed so this doesn’t really help.

From what I’d believe you’re trying to do is achieve it changing it’s num / printing the true-walkspeed of the humanoid.

However I’m unsure if you’re using server or local.

I need a bit more depth into detail of what you want to achieve necessarily.

Server (I said it was in the humanoid, localscripts can’t run there). I’m trying to make the sparkles enable at 85+ walkspeed. Have you read the post or did you only read the codeblock??

To be quite frank with you, your explanation doesn’t really do you any justice. We need more information to be able to help you.

Okay.

I’m making a Sonic game with this ability called ‘Overdrive’ and I want there to be a sparkle effect coming from the HumanoidRootPart when you reach 85 walkspeed or above, but it won’t enable.

It continously prints “22” which is VERY frustrating, as this means it can’t enable.

It’s been extremely hard to, and I am about to go to my last resort.

Dang it! it prints the starter character’s walkspeed! Big problem!

How do I fix this?

Why does it print the starter character’s walkspeed when it’s in a different character with a completely different walkspeed?

You can however do this

wait(.1)
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")

while wait() do
	if Humanoid.Health > 0 then
		if Humanoid.WalkSpeed >= 85 then
			print("true")
		else
			print("false")
		end
	end
end

This is the same exact code almost but however this could work unsure, but this might help you out.

You can put a script into the starter character / the script I gave you and it should work if you put it in there so it loads into it. (maybe.)

I’m not at all mostly familiar with starter-character models.

Edit-Detail:
Put it in the model thats replacing the current model of a default character.

Now the script doesn’t even run, I added an if statement to check if it’s not in the startercharacter

I see, I think what I’m believing currently is you want the actual speed of the player moving correct?

No, not the velocity, the walkspeed. I’m probably going to spend hours on this trying to fix it, so I’ll just handle it in the startergui. Thank you

Hello. I’m not sure if you are still willing to try and do what you were doing originally. If you are, I believe I have a solution to your problem. I’ve tested it in my own baseplate and it works flawlessly. I’ll share the scripts I used, and where to put them.

First one:

game.Players.PlayerAdded:Connect(function(player) -- Detect when player joins
	player.CharacterAdded:Connect(function(char) -- Detect when player's character is added
		local newScript = game:GetService("ServerStorage"):WaitForChild("DetectChangeInWalkspeed"):Clone() -- Get the Script that detects when the walkspeed has changed, and parent it to the player's character
		newScript.Parent = char
		
		local particleEmitter = game:GetService("ServerStorage"):WaitForChild("ParticleEmitter"):Clone() -- Create a clone of the particle emitter and parent it to HumanoidRootPart
		particleEmitter.Parent = char.HumanoidRootPart
	end)
end)

This script is stored in ServerScriptService, and will create and parent a new Walkspeed detecting script and particle emitter anytime a new player joins the game.

Second one:

local humanoid = script.Parent.Humanoid -- Get the character's humanoid

humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function() -- Detect whenever walkspeed changes
	print(humanoid.WalkSpeed)
	if humanoid.WalkSpeed > 85 then
		script.Parent.HumanoidRootPart.ParticleEmitter.Enabled = true
	else
		script.Parent.HumanoidRootPart.ParticleEmitter.Enabled = false
	end
end)

This script is stored in ServerStorage and is the script that gets cloned into the character by the first script I pasted. Using the GetPropertyChangedSignal() function, we can detect whenever the humanoid’s walkspeed changes.

Third one (optional):

game.Players.PlayerAdded:Connect(function(player) -- Detect when new player joins the game
	player.CharacterAdded:Connect(function(char) -- Detect when that player's character has loaded
		while true do -- Create a while loop
			task.wait(0.5)
			for i, v in ipairs(game.Players:GetPlayers()) do -- Loop through all players in the game
				v.Character.Humanoid.WalkSpeed += 1 -- Create a path to the player's humanoid and increase walkspeed by 1 every 0.5 seconds
			end
		end
	end)
end)

This last script is optional, however I do have something important to share. If you were previously updating the walkspeed of the player through a localscript, then that could be why the server wasn’t picking up the change in the walkspeed, because the change won’t be replicated to the server, meaning it can’t detect it. The second script I pasted is a server script, meaning that it will only detect changes to the walkspeed on the server, so you’ll have to update the walkspeed on the server, which is what this script does.

Hopefully you can use these scripts or at least integrate the ideas used in them into your own scripts. If you want to try and handle everything through startergui or whatever, you can, but this is an idea that could work for you I think. Let me know if you have any troubles or questions.

1 Like

Wow, didn’t expect this. I already fixed it though. Thanks a ton anyway!