Walk faster on part

hello people, im trying to make that if you have a tool equipped and you walk on a part with the name “SugarPaste”, it makes you go faster. Here is the code i wrote that doesnt works. Can anyone tell me why? Also how do i get the humanoid from the hit

spssf.Touched:Connect(function(hit)
	if equipped == true then
		if spssf.Name == "SugarPaste" then
			print("something")
		end
	end
end)
local bonusSpeed = 10 -- your value here
local debounce = false

spssf.Touched:Connect(function(hit)
     -- Find the player character
     if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
          debounce = true

          -- If there's a tool in the character, it is equipped.
          local tool = hit.Parent:FindFirstChildOfClass("Tool") or nil

          -- If tool is named "SugarPaste", give bonus speed
          if tool ~= nil and tool.Name == "SugarPaste" then
               hit.Parent.Humanoid.WalkSpeed += bonusSpeed
          end

          task.wait(1)
          debounce = false
     end
end)

EDIT:
Added a debounce so it prevents the Touched event from firing multiple times when a player touches the part.

Sorry but it does not do anything

Oh my bad i forgot to precise that this script was meant to be written in a tool

So instead of @Auxicon’s script asking if the tool.Name == “SugarPaste” check to see if the Humanoid has the correct tool enabled.
You can put this script inside each SugarPaste Part if there are only a few in a map.
Either that or when the tool.Enabled property changes enable the Touched function to see if the Player is contacting the SugarPaste Part.

Thanks, it works. But how would i make the speed boost dissapear after the player stops touching the part

Nevermind i figured it out. Thanks again!

Oh awesome! Good luck on your project.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.