Walkspeed change in script

In my script, I need to add a part that makes the walkspeed go to 0 for a certain amount of time but its not working. The part thats not working is at the end of the script. I would really appreciate any help. If more explination is needed tell me, and ill explain your question. Thank you

local Teams = game:GetService("Teams")
local ServerStorage = game:GetService("ServerStorage")
local StadiumLocation = workspace:WaitForChild("StadiumLocation")
local Players = game:GetService("Players")
local PlayerNotToKill = PlayerObj
local blueSpawn
local redSpawn
local GameCountDownPlrSpeed = 0
local StartingMatchPlrSpeed = 16
local GameIsReadyToStart = false


game.ReplicatedStorage.LoadStadium.OnServerEvent:Connect(function()
	local StadiumFolder = ServerStorage.StadiumFolder:GetChildren()
	for _, FutStadium in ipairs(StadiumFolder) do
		local NewStadium = FutStadium:Clone()
		FutStadium.Parent = StadiumLocation
	end
	print("Stadium has loaded")
	game.ServerScriptService.GameScript.Enabled = true
	wait(2)
	for _,plr in next, game:GetService("Players"):GetPlayers() do
		if plr.Character and plr ~= PlayerNotToKill then plr.Character:BreakJoints()
			
		end	
	end
	wait(0.1)
	blueSpawn = workspace.StadiumLocation.FutStadium.SoccerThings.Team1Spawn
	redSpawn = workspace.StadiumLocation.FutStadium.SoccerThings.Team2Spawn
	
	for index, player in ipairs(Teams["Blue"]:GetPlayers()) do
		local character = player.Character or player.CharacterAdded:Wait()
		character.PrimaryPart.CFrame = blueSpawn.CFrame
	end
	for index, player in ipairs(Teams["Red"]:GetPlayers()) do
				local character = player.Character or player.CharacterAdded:Wait()
		character.PrimaryPart.CFrame = redSpawn.CFrame
	end
	wait(0.1)

				Humanoid.WalkSpeed = (GameCountDownPlrSpeed)
				if GameIsReadyToStart == false then
					GameIsReadyToStart = true
				end
			end
	

			
			
				
	
game.ReplicatedStorage.MatchStartTimer.OnServerEvent:Connect(function
	
	if GameIsReadyToStart == true then
		if Humanoid then
			Humanoid.WalkSpeed = (StartingMatchPlrSpeed)
		end
end)
3 Likes

Could it be that you are missing “()” when calling a function?

game.ReplicatedStorage.MatchStartTimer.OnServerEvent:Connect(function() -- seems to me you missed the two parentheses after "function"
	
	if GameIsReadyToStart == true then
		if Humanoid then
			Humanoid.WalkSpeed = (StartingMatchPlrSpeed)
		end
end)
3 Likes

No its not that, the problem is that i cant find the humanoid

of course you can’t find the humanoid you’re not defining what it is

game.ReplicatedStorage.MatchStartTimer.OnServerEvent:Connect(function(player)
	local Humanoid = player.Character.Humanoid
	if GameIsReadyToStart == true then
		if Humanoid then
			Humanoid.WalkSpeed = (StartingMatchPlrSpeed)
		end
end)
3 Likes