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.
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")
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.
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")
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)
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)