-
Notifications
You must be signed in to change notification settings - Fork 0
/
newEstsprint.lua
194 lines (157 loc) · 5.74 KB
/
newEstsprint.lua
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
local Parent = game.Players.LocalPlayer.PlayerGui
local Sprint = Instance.new("Frame")
local ImageLabel = Instance.new("ImageLabel")
local UICorner = Instance.new("UICorner")
local UIPadding = Instance.new("UIPadding")
local Bar = Instance.new("Frame")
local UICorner_2 = Instance.new("UICorner")
local UIPadding_2 = Instance.new("UIPadding")
local Fill = Instance.new("Frame")
local UICorner_3 = Instance.new("UICorner")
--Properties:
local StaminaGui = Instance.new("ScreenGui")
--Properties:
StaminaGui.Name = "StaminaGui"
StaminaGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
StaminaGui.Enabled = true
StaminaGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
Sprint.Name = "Sprint"
Sprint.Parent = StaminaGui
Sprint.AnchorPoint = Vector2.new(0, 1)
Sprint.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Sprint.BackgroundTransparency = 1.000
Sprint.Position = UDim2.new(0.931555569, 0, 0.987179458, 0)
Sprint.Size = UDim2.new(0.0556001104, 0, 0.0756410286, 0)
Sprint.SizeConstraint = Enum.SizeConstraint.RelativeYY
Sprint.ZIndex = 1005
ImageLabel.Parent = Sprint
ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 222, 189)
ImageLabel.Size = UDim2.new(1, 0, 1, 0)
ImageLabel.SizeConstraint = Enum.SizeConstraint.RelativeYY
ImageLabel.Visible = false
UICorner.CornerRadius = UDim.new(1, 0)
UICorner.Parent = ImageLabel
UIPadding.Parent = Sprint
UIPadding.PaddingBottom = UDim.new(0.300000012, -5)
UIPadding.PaddingLeft = UDim.new(0.0199999996, 0)
UIPadding.PaddingRight = UDim.new(0.0500000007, -15)
UIPadding.PaddingTop = UDim.new(0.300000012, -5)
Bar.Name = "Bar"
Bar.Parent = Sprint
Bar.AnchorPoint = Vector2.new(0, 0.5)
Bar.BackgroundColor3 = Color3.fromRGB(56, 46, 39)
Bar.BackgroundTransparency = 0.700
Bar.Position = UDim2.new(-2.72600269, 0, 0.499999672, 0)
Bar.Size = UDim2.new(3.60599804, 0, 0.600000083, 0)
Bar.ZIndex = 0
UICorner_2.CornerRadius = UDim.new(0.25, 0)
UICorner_2.Parent = Bar
UIPadding_2.Parent = Bar
UIPadding_2.PaddingBottom = UDim.new(0, 4)
UIPadding_2.PaddingLeft = UDim.new(0, 4)
UIPadding_2.PaddingRight = UDim.new(0, 4)
UIPadding_2.PaddingTop = UDim.new(0, 4)
Fill.Name = "Fill"
Fill.Parent = Bar
Fill.AnchorPoint = Vector2.new(0, 0.5)
Fill.BackgroundColor3 = Color3.fromRGB(213, 185, 158)
Fill.Position = UDim2.new(0, 0, 0.5, 0)
Fill.Size = UDim2.new(1, 0, 1, 0)
Fill.ZIndex = 2
UICorner_3.CornerRadius = UDim.new(0.25, 0)
UICorner_3.Parent = Fill
local erm = Instance.new("ScreenGui")
local ImageLabel = Instance.new("ImageLabel")
erm.IgnoreGuiInset = true
erm.Name = "erm"
erm.Parent = Parent
erm.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ImageLabel.Parent = erm
ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
ImageLabel.BackgroundTransparency = 1.000
ImageLabel.Size = UDim2.new(1, 0, 0.998717964, 0)
ImageLabel.Image = "rbxassetid://190596490"
ImageLabel.ImageColor3 = Color3.fromRGB(0, 0, 0)
ImageLabel.ImageTransparency = 1
-- Services
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
-- Variables
local Plr = Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")
local stamina, staminaMax = 100, 100
local sprintTime = 7
local cooldown = false
local ModuleScripts = {
MainGame = require(Plr.PlayerGui.MainUI.Initiator.Main_Game),
}
-- Setup
local nIdx; nIdx = hookmetamethod(game, "__newindex", newcclosure(function(t, k, v)
if k == "WalkSpeed" then
if ModuleScripts.MainGame.chase then
v = ModuleScripts.MainGame.crouching and 15 or 22
elseif ModuleScripts.MainGame.crouching then
v = 8
else
v = isSprinting and 20 or 12
end
end
return nIdx(t, k, v)
end))
-- Scripts
sprintTime = math.max(sprintTime - 1, 1)
local zerostamtween = game.TweenService:Create(ImageLabel,TweenInfo.new(12),{ImageTransparency = 0})
UIS.InputBegan:Connect(function(key, gameProcessed)
if not gameProcessed and key.KeyCode == Enum.KeyCode.Q and not cooldown and not ModuleScripts.MainGame.crouching then
-- Sprinting
isSprinting = true
Hum:SetAttribute("SpeedBoost",4)
zerostamtween:Play()
while UIS:IsKeyDown(Enum.KeyCode.Q) and stamina > 0 do
stamina = math.max(stamina - 1, 0)
Fill.Size = UDim2.new(1 / staminaMax * stamina, 1, 1, 0)
task.wait(sprintTime / 100)
end
-- Reset
zerostamtween:Pause()
isSprinting = false
Hum:SetAttribute("SpeedBoost",0)
game.TweenService:Create(ImageLabel,TweenInfo.new(1),{ImageTransparency = 1}):Play()
Hum.WalkSpeed = 12
if stamina == 0 then
-- Cooldown
firesignal(game.ReplicatedStorage.Bricks.Caption.OnClientEvent,"You're exhausted.")
local noStamernaSound = Instance.new("Sound",workspace)
noStamernaSound.SoundId = "rbxassetid://8258601891"
noStamernaSound.Volume = 0.8
noStamernaSound.PlayOnRemove = true
noStamernaSound:Destroy()
cooldown = true
game.TweenService:Create(ImageLabel,TweenInfo.new(0.3),{ImageTransparency = 0}):Play()
wait(0.3)
game.TweenService:Create(ImageLabel,TweenInfo.new(10),{ImageTransparency = 1}):Play()
for i = 1, staminaMax, 1 do
stamina = i
Fill.Size = UDim2.new(1 / staminaMax * i, 1, 1, 0)
task.wait(sprintTime / 50)
end
cooldown = false
else
-- Refill
cooldown = false
Spawn(function()
--wait(1)
cooldown = false
end)
game.TweenService:Create(ImageLabel,TweenInfo.new(1),{ImageTransparency = 1}):Play()
while not UIS:IsKeyDown(Enum.KeyCode.Q) do
stamina = math.min(stamina + 1, staminaMax)
Fill.Size = UDim2.new(1 / staminaMax * stamina, 1, 1, 0)
task.wait(sprintTime / 50)
end
end
end
end)
Hum:SetAttribute("SpeedBoost",0)
Hum.WalkSpeed = 12