Menu
CoddyTech

Speed Pad

Part of the Roblox Game Scripting section of Coddy's Lua journey. Lesson 17 of 24.

The Humanoid controls how a character moves. Two of its properties:

  • WalkSpeed: studs per second, 16 by default
  • JumpHeight: how high the character jumps, in studs, 7.2 by default

Changing them on touch makes power-ups. This pad slows down anyone who steps on it:

local mud = script.Parent
mud.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.WalkSpeed = 8
	end
end)

The change lasts until something sets the value again or the character respawns: a new character starts with the defaults.

challenge icon

Challenge

Medium

The finish line is 78 studs past the pad. At normal speed that takes about 5 seconds, and the course wants it done in under 2.2.

The script is inside the green pad. When a character touches it, set its WalkSpeed to 50. Players should keep the normal speed until they reach the pad, and a falling ball must not cause an error.

Press Play and race to the yellow line, then Check.

Try it yourself

local pad = script.Parent

pad.Touched:Connect(function(hit)
	-- Find the Humanoid and make it run at speed 50
end)
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Roblox Game Scripting

Practice on your own: Online Lua compiler