local player = game.Players.LocalPlayer
local userInput = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local round = game.ReplicatedStorage.values.round
local ContextActionService = game:GetService"ContextActionService"
local stamina = 0
local canRun = false
local running = false
local canSprint = true
local canRegen = true
math.clamp(stamina, 0, 90.7)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear
)
local function remove(obj)
task.wait(15)
obj:Destroy()
end
local function sight()
for _, v in next, game.Players:GetPlayers() do
local plr = v
if v.Character then
if plr.Character:FindFirstChild("survivor") then
local sight = game.ReplicatedStorage.models.benSight:Clone()
sight.Parent = plr.Character.HumanoidRootPart
task.spawn(remove, sight)
end
end
end
end
local bar = player.PlayerGui:WaitForChild("sightGui").background.Frame
local function buttonPressed(name, state, input)
local char = player.Character
local bar = player.PlayerGui:WaitForChild("sightGui").background.Frame
if state == Enum.UserInputState.Begin and canSprint == true and game.ReplicatedStorage.values.round.Value == true and char.HumanoidRootPart:FindFirstChild("IAmMonster") and not char:FindFirstChild("survivor") then
canRun = true
running = true
while stamina >= 0 and running == true do
if stamina >= 90.7 then
game.ReplicatedStorage.events.screamEvent:FireServer()
task.spawn(sight)
stamina -= 90.7
end
if stamina <= 75 and stamina > 50 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(144, 156, 36)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
if stamina <= 50 and stamina > 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(161, 99, 33)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
bar:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
task.wait()
end
else
if game.ReplicatedStorage.values.round.Value == true and char.HumanoidRootPart:FindFirstChild("IAmMonster") and not char:FindFirstChild("survivor") then
running = false
if canRegen == true then
while stamina < 90.7 and not running do
stamina += .02
canRegen = false
if stamina >= 75 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(0, 160, 0)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
if stamina <= 75 and stamina > 50 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(144, 156, 36)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
if stamina <= 50 and stamina > 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(161, 99, 33)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(bar, tweenInfo, Goal):Play()
end
bar:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
task.wait()
end
end
canRegen = true
end
end
return Enum.ContextActionResult.Pass
end
function placeButton()
print("i hope i work")
task.wait(9.5)
local char = player.Character or player.CharacterAdded:Wait()
if char:WaitForChild("HumanoidRootPart"):FindFirstChild("IAmMonster") then
print("i worked")
ContextActionService:SetPosition("sightButton",UDim2.new(0.72,-20,0.20,-20))
ContextActionService:SetTitle("sightButton","Sight")
end
end
game.ReplicatedStorage.values.round.Changed:Connect(function()
local char
local sprintButton = ContextActionService:BindAction("sightButton", buttonPressed, true)
ContextActionService:SetPosition("sightButton",UDim2.new(0,0,500,0))
ContextActionService:SetTitle("sightButton","Sight")
if game.ReplicatedStorage.values.round.Value == true then
print("i am true")
task.wait(9.5)
print("oml")
char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
if game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart"):FindFirstChild("IAmMonster") then
print("i worked")
ContextActionService:SetPosition("sightButton",UDim2.new(0.72,-20,0.20,-20))
ContextActionService:SetTitle("sightButton","Sight")
end
end
if game.ReplicatedStorage.values.round.Value == false then
print("now im false???")
ContextActionService:UnbindAction("sightButton")
ContextActionService:SetPosition("sightButton",UDim2.new(0,0,500,0))
ContextActionService:SetTitle("sightButton","Sight")
end
end)
script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
running = false
if canRegen == true then
while stamina < 90.7 and not running do
stamina += .02
canRegen = false
if stamina >= 75 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(0, 160, 0)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 75 and stamina > 50 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(144, 156, 36)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 50 and stamina > 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(161, 99, 33)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
task.wait()
end
end
canRegen = true
userInput.InputBegan:Connect(function(input)
local char = player.Character
if input.KeyCode == Enum.KeyCode.E and canSprint == true and round.Value == true and not char:FindFirstChild("survivor") then
canRun = true
running = true
while stamina >= 0 and running == true do
if stamina >= 90.7 then
game.ReplicatedStorage.events.screamEvent:FireServer()
task.spawn(sight)
stamina -= 90.7
end
if stamina <= 75 and stamina > 50 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(144, 156, 36)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 50 and stamina > 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(161, 99, 33)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
task.wait()
end
end
end)
userInput.InputEnded:Connect(function(input)
local char = player.Character
if input.KeyCode == Enum.KeyCode.E and round.Value == true and char.HumanoidRootPart:FindFirstChild("IAmMonster") and not char:FindFirstChild("survivor") then
running = false
if canRegen == true then
while stamina < 90.7 and not running do
stamina += .02
canRegen = false
if stamina >= 75 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(0, 160, 0)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 75 and stamina > 50 then
canSprint = true
local Goal = {BackgroundColor3 = Color3.fromRGB(144, 156, 36)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 50 and stamina > 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(161, 99, 33)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
if stamina <= 25 then
canSprint = false
local Goal = {BackgroundColor3 = Color3.fromRGB(168, 0, 24)}
tweenService:Create(script.Parent, tweenInfo, Goal):Play()
end
script.Parent:TweenSize(UDim2.new(stamina / 100, 0, 0.7 ,0), "Out", "Linear", 0)
task.wait()
end
end
canRegen = true
end
end)