Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to change the speed of the player when clicking on a tool?

Hello guys, I wanted to make a drink of speed, so my idea was to take the "Bloxy cola" and adapt a little, that for when drinking increase the speed of the player, so I triggered it ... Have I tried anyway, I mislocated the location or the script?

h.Player.WalkSpeed = 50

1 answer

✓ Accepted answer

Add a script on the tool, then put this: Change the speed to what speed you want when you drinked it

local Tool = script.Parent;
local Speed = 30 -- change the speed to whatever you like!

enabled = true

function onActivated()
	if not enabled  then
		return
	end

	enabled = false
	Tool.GripForward = Vector3.new(0,-.759,-.651)
	Tool.GripPos = Vector3.new(1.5,-.5,.3)
	Tool.GripRight = Vector3.new(1,0,0)
	Tool.GripUp = Vector3.new(0,.651,-.759)


	Tool.Handle.DrinkSound:Play()

	wait(3)
	
	local h = Tool.Parent:FindFirstChild("Humanoid")
	h.WalkSpeed = Speed
	if (h ~= nil) then
		if (h.MaxHealth > h.Health + 5) then
			h.Health = h.Health + 5
		else	
			h.Health = h.MaxHealth
		end
	end

	Tool.GripForward = Vector3.new(-.976,0,-0.217)
	Tool.GripPos = Vector3.new(0.03,0,0)
	Tool.GripRight = Vector3.new(.217,0,-.976)
	Tool.GripUp = Vector3.new(0,1,0)

	enabled = true

end

function onEquipped()
	Tool.Handle.OpenSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

Hope this helps! :D Accept the answer if it worked

This discussion is preserved as it was. New answers, comments, and votes are closed.