I made a Crawl and Crouch system, and I need help fixing my script where it removes the starterpack UI and Unequips your tools, whenever you activate the Crouch or Crawl.
Removing the UI whenever I crouch works, but The UI comes back after a few seconds, I want it to stay removed until the player stops crouching, or crawling.
– Here’s the script:
local l__UserInputService__2 = game:GetService("UserInputService");
local l__TweenService__3 = game:GetService("TweenService");
local l__LocalPlayer__4 = game:GetService("Players").LocalPlayer;
local l__Run__5 = l__LocalPlayer__4:WaitForChild("PlayerGui"):WaitForChild("Run");
local l__Humanoid__6 = l__LocalPlayer__4.Character:WaitForChild("Humanoid");
local v7 = {};
local v8 = require(game.ReplicatedStorage.Weapon_Module);
local v9 = 0;
local v10 = 0;
local l__next__11 = next;
local v12, v13 = script:GetChildren();
while true do
local v14, v15 = l__next__11(v12, v13);
if not v14 then
break;
end;
v13 = v14;
v7[v15.Name] = l__Humanoid__6:LoadAnimation(v15);
end;
local u1 = nil;
local u2 = false;
function setCrouch(p1)
u1 = p1;
if u1 then
if not u2 then
l__Humanoid__6.Parent.Crouched.Value = "Crouch";
spawn(function()
v8.Tween_Camera_Offset2(Vector3.new(0.003, 0, -0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(-0.003, -0, 0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0, -0, 0), 0.2);
end);
if not v7.Crouch.IsPlaying then
v7.Crouch:Play(0.3);
game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
l__StarterGui__1:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end;
if v7.CrawlWalk.IsPlaying then
v7.CrawlWalk:Stop(0.1);
end;
l__Humanoid__6.WalkSpeed = 5;
return;
end;
end;
if u1 then
if u2 then
l__Humanoid__6.Parent.Crouched.Value = "Crawl";
if not v7.Crawl.IsPlaying then
v7.Crawl:Play(0.5);
end;
if v7.CrouchWalk.IsPlaying then
v7.CrouchWalk:Stop(0.3);
end;
end;
end;
end;
local u3 = false;
function stand(p2)
if p2 == true then
spawn(function()
v8.Tween_Camera_Offset2(Vector3.new(-0.003, 0, 0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0.003, -0, -0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0, -0, 0), 0.2);
end);
l__Humanoid__6.Parent.Crouched.Value = "";
u3 = false;
local l__next__16 = next;
local v17 = nil;
while true do
local v18, v19 = l__next__16(v7, v17);
if v18 then
else
break;
end;
v17 = v18;
if v19 ~= v7.Crawl then
if v19 == v7.CrawlWalk then
v19:Stop(0.5);
else
v19:Stop(0.2);
end;
else
v19:Stop(0.5);
end;
end;
if u2 == true then
v7.CrawlUp:Play(0.2);
wait(0.5);
l__Humanoid__6.WalkSpeed = 6;
else
wait(0.2);
l__Humanoid__6.WalkSpeed = 6;
end;
u2 = false;
end;
if u3 == true then
spawn(function()
v8.Tween_Camera_Offset2(Vector3.new(-0.003, 0, 0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0.003, -0, -0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0, -0, 0), 0.2);
end);
u3 = false;
u2 = false;
local l__next__20 = next;
local v21 = nil;
while true do
local v22, v23 = l__next__20(v7, v21);
if v22 then
else
break;
end;
v21 = v22;
if v23 ~= v7.Crawl then
if v23 == v7.CrawlWalk then
v23:Stop(0.5);
else
v23:Stop(0.2);
end;
else
v23:Stop(0.5);
end;
end;
l__Humanoid__6.Parent.Crouched.Value = "";
l__Humanoid__6.WalkSpeed = 6;
return;
end;
if u3 == false then
if u2 == true then
spawn(function()
v8.Tween_Camera_Offset2(Vector3.new(-0.003, 0, 0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0.003, -0, -0.005), 0.3);
wait(0.3);
v8.Tween_Camera_Offset2(Vector3.new(0, -0, 0), 0.2);
end);
l__Humanoid__6.Parent.Crouched.Value = "Crouch";
if not v7.Crouch.IsPlaying then
v7.Crouch:Play(0.3);
end;
u3 = true;
u2 = false;
local l__next__24 = next;
local v25 = nil;
while true do
local v26, v27 = l__next__24(v7, v25);
if v26 then
else
break;
end;
v25 = v26;
if v27.Name ~= "Crawl" then
if v27.Name == "CrawlWalk" then
v27:Stop(0.5);
end;
else
v27:Stop(0.5);
end;
end;
wait(0.4);
l__Humanoid__6.WalkSpeed = 5;
end;
end;
end;
l__Humanoid__6.Seated:Connect(function(p3)
if u3 or u2 then
l__Humanoid__6.Sit = false;
stand(true);
end;
end);
l__Humanoid__6.HealthChanged:Connect(function(p4)
if p4 < 26 and v7.Crouch.IsPlaying then
stand(true);
end;
if p4 < 26 and v7.Crawl.IsPlaying then
stand(true);
end;
end);
local u4 = false;
l__UserInputService__2.InputBegan:Connect(function(p5, p6)
if u3 == false and not u2 and p5.KeyCode.Name == "C" and not u4 and l__Humanoid__6.Health > 26 and l__Humanoid__6.Sit == false and not l__UserInputService__2:GetFocusedTextBox() then
u4 = true;
u3 = true;
u2 = false;
wait();
setCrouch(true);
wait(0.2);
u4 = false;
return;
end;
if u3 == true and not u2 and p5.KeyCode.Name == "C" and not u4 and l__Humanoid__6.Health > 26 and not l__Humanoid__6.Sit == true and not l__UserInputService__2:GetFocusedTextBox() then
u4 = true;
u3 = false;
u2 = true;
l__Humanoid__6.WalkSpeed = 0;
wait();
setCrouch(true);
wait(0.4);
if u2 then
l__Humanoid__6.WalkSpeed = 4;
end;
wait(0.2);
u4 = false;
return;
end;
if p5.KeyCode.Name == "V" and not u4 and l__Humanoid__6.Health > 26 and not l__UserInputService__2:GetFocusedTextBox() then
u4 = true;
if u2 == true then
l__Humanoid__6.WalkSpeed = 0;
end;
wait();
stand();
wait(0.2);
u4 = false;
return;
end;
if p5.KeyCode.Name == "LeftShift" and l__Humanoid__6.Health > 26 and not l__UserInputService__2:GetFocusedTextBox() and (u2 == true or u3 == true) then
wait(0.2);
if l__UserInputService__2:IsKeyDown(Enum.KeyCode.LeftShift) then
l__Humanoid__6.WalkSpeed = 0;
wait();
stand(true);
if l__UserInputService__2:IsKeyDown(Enum.KeyCode.LeftShift) then
l__LocalPlayer__4.PlayerGui.Run.Murena.Value = not l__LocalPlayer__4.PlayerGui.Run.Murena.Value;
end;
end;
end;
end);
while wait(0.05) do
local v28 = l__Humanoid__6.Parent.HumanoidRootPart.Velocity.Magnitude > 0.1;
if (l__Humanoid__6.Health < 26 or not (not l__Humanoid__6.Parent:FindFirstChild("Ragdolled")) or l__Humanoid__6.Parent:FindFirstChild("SETRagdolled")) and (u2 == true or u3 == true) then
v28 = false;
u2 = false;
stand(true);
end;
if v28 == true and not v7.CrouchWalk.IsPlaying and u3 and v7.Crouch.IsPlaying then
v7.CrouchWalk:Play(0.4);
if v9 ~= nil then
v7.CrouchWalk.TimePosition = v9;
end;
elseif v28 == false and v7.CrouchWalk.IsPlaying then
v9 = v7.CrouchWalk.TimePosition;
v7.CrouchWalk:Stop(0.4);
elseif v7.Crouch.IsPlaying == false and v7.CrouchWalk.IsPlaying then
v9 = v7.CrouchWalk.TimePosition;
v7.CrouchWalk:Stop(0.4);
end;
if v28 == true and not v7.CrawlWalk.IsPlaying and u2 and v7.Crawl.IsPlaying then
v7.CrawlWalk:Play(0.4);
v7.Armsmove:Play(0.4);
v7.Armsidle:Stop(0.2);
if v10 ~= nil then
v7.CrawlWalk.TimePosition = v10;
v7.Armsmove.TimePosition = v10;
end;
elseif v28 == false and v7.CrawlWalk.IsPlaying then
v10 = v7.CrawlWalk.TimePosition;
v7.CrawlWalk:Stop(0.4);
v7.Armsidle:Play(0.2);
v7.Armsmove:Stop(0.4);
elseif v7.Crawl.IsPlaying == false and v7.CrawlWalk.IsPlaying then
v10 = v7.CrawlWalk.TimePosition;
v7.CrawlWalk:Stop(0.4);
v7.Armsidle:Play(0.2);
v7.Armsmove:Stop(0.4);
end;
if v28 == true and not v7.Armsmove.IsPlaying and u2 then
v7.Armsmove:Play(0.4);
if v10 ~= nil then
v7.Armsmove.TimePosition = v10;
end;
elseif v28 == false and v7.Armsmove.IsPlaying then
v7.Armsmove:Stop(0.4);
elseif v7.Crawl.IsPlaying == false and v7.Armsmove.IsPlaying then
v7.Armsmove:Stop(0.4);
end;
if v7.Crawl.IsPlaying then
v7.Armsidle:Play(0.2);
end;
if game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool") or u3 and not u2 then
if u3 and not u2 then
v7.Armsmove:Stop(0.2);
v7.Armsidle:Stop(0.2);
elseif game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool") then
v7.Armsmove:Stop(0.2);
v7.Armsidle:Stop(0.2);
end;
end;
if u3 == false and u2 == false then
if (workspace.CurrentCamera.Focus.p - workspace.CurrentCamera.CoordinateFrame.p).Magnitude > 1 and l__Humanoid__6.Sit == false and (l__Humanoid__6.CameraOffset == Vector3.new(0, -1, 0) or l__Humanoid__6.CameraOffset == Vector3.new(0, -2.7, 0)) then
l__TweenService__3:Create(l__LocalPlayer__4.Character.Humanoid, TweenInfo.new(0.2), {
CameraOffset = Vector3.new(0, 0, 0)
}):Play();
end;
elseif (workspace.CurrentCamera.Focus.p - workspace.CurrentCamera.CoordinateFrame.p).Magnitude > 1 and l__Humanoid__6.Sit == false then
if u2 == false then
l__TweenService__3:Create(l__LocalPlayer__4.Character.Humanoid, TweenInfo.new(0.2), {
CameraOffset = Vector3.new(0, -1, 0)
}):Play();
else
l__TweenService__3:Create(l__LocalPlayer__4.Character.Humanoid, TweenInfo.new(0.2), {
CameraOffset = Vector3.new(0, -2.7, 0)
}):Play();
end;
end;
end;