Trying to change walkspeed if a player is r15

  1. What do you want to achieve? I want to make the player’s walkspeed lower if their character is R15, and keep their walkspeed at the default if they are R6. My entire reason for doing this is because the walking sounds are sped up when using Realism on an R15 character.

  2. What is the issue? My script doesn’t work. Here it is.

-- ServerScript in StarterCharacterScripts
local hm = script.Parent:WaitForChild("Humanoid")
local rigtype = hm.RigType

if rigtype == "R15" then
	hm.WalkSpeed = 12
else
	hm.WalkSpeed = 16
end

warn("Checking if script is running")
  1. What solutions have you tried so far? I can’t imagine I’ll find anything on the toolbox, and I can’t find anything about this issue on here.

Any help is appreciated, thanks

1 Like
local hm = script.Parent:WaitForChild("Humanoid")
local rigtype = hm.RigType

if rigtype == Enum.HumanoidRigType.R15 then
	hm.WalkSpeed = 12
else
	hm.WalkSpeed = 16
end

warn("Checking if script is running")
2 Likes

Czopek got it, but I would suggest moving the script under ServerScriptService, so you do not need to have multiple scripts under each character.

local Players = game:GetService("Players")

function OnCharacterAdded(Character)
	local Humanoid = Character:WaitForChild("Humanoid")
	
	if Humanoid.RigType == Enum.HumanoidRigType.R15 then
		Humanoid.WalkSpeed = 12
	else
		Humanoid.WalkSpeed = 16
	end
end

function OnPlayerAdded(player)
	if player.Character then
		OnCharacterAdded(player.Character)
	end

	player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
3 Likes

I put it into ServerScriptService, but it does not work.
image

I even put a test print at the end to make sure the script’s running, and sure enough…
image

And yes, my character is R15.
image

1 Like

My bad, it should have been HumanoidRigType.

local Players = game:GetService("Players")

function OnCharacterAdded(Character)
	local Humanoid = Character:WaitForChild("Humanoid")
	
	if Humanoid.RigType == Enum.HumanoidRigType.R15 then
		Humanoid.WalkSpeed = 12
	else
		Humanoid.WalkSpeed = 16
	end
end

function OnPlayerAdded(player)
	if player.Character then
		OnCharacterAdded(player.Character)
	end

	player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
3 Likes