-
Notifications
You must be signed in to change notification settings - Fork 0
/
speed boost
26 lines (25 loc) · 856 Bytes
/
speed boost
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- Gives temporary speed boost
local FastSpeed = 80 -- speed to set the player
local BoostTime = 3 -- how many seconds should the boost last
local speedBoost = script.Parent
local boostRunningNum = 0; --keep track of if given multiple times
local function onTouch(otherPart)
-- Looks for a humanoid and stores it
local character = otherPart.Parent
local humanoid = character:FindFirstChildWhichIsA ("Humanoid")
-- Print statement for debugging
if humanoid then
print("A humanoid touched speedBoost")
-- Change to faster speed, wait, then change to normal
humanoid.WalkSpeed = FastSpeed
boostRunningNum += 1
print("Player is moving super fast")
wait(BoostTime)
boostRunningNum -= 1
if boostRunningNum <= 0 then
humanoid.WalkSpeed = 16
print("Player is back at normal speed")
end
end
end
speedBoost.Touched:Connect(onTouch)