Advertisement
kaenzyKZ

Be NPC or Die script

Dec 30th, 2024 (edited)
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.65 KB | Gaming | 0 0
  1. -- or copy this loadstring(game:HttpGet("https://pastebin.com/raw/ZQZkLUz3",true))()
  2. --------------------------------------------------------------------------------
  3. --// Services
  4. --------------------------------------------------------------------------------
  5. local Players = game:GetService("Players")
  6. local Teams = game:GetService("Teams")
  7. local Workspace = game:GetService("Workspace")
  8. local TweenService = game:GetService("TweenService")
  9. local VirtualInputManager = game:GetService("VirtualInputManager")
  10. local UserInputService = game:GetService("UserInputService")
  11.  
  12. --------------------------------------------------------------------------------
  13. --// Locals & Globals
  14. --------------------------------------------------------------------------------
  15. local LocalPlayer = Players.LocalPlayer
  16.  
  17. _G.ensureloop = true  -- For billboard loop
  18.  
  19. -- We'll store all connections here to clean them up on Kill
  20. local connections = {}
  21. local function bindConnection(signal, func)
  22.     local connection = signal:Connect(func)
  23.     table.insert(connections, connection)
  24.     return connection
  25. end
  26.  
  27. --// Infinite Stamina
  28. local stamina = game:GetService("Players").LocalPlayer.PlayerGui.Modules.Gameplay.Sprint.Stamina
  29. stamina.Value = math.huge
  30. staminaActive = true
  31. if staminaActive then
  32.     bindConnection(stamina:GetPropertyChangedSignal("Value"), function()
  33.     if stamina.Value ~= math.huge then
  34.         stamina.Value = math.huge
  35.     end
  36. end)
  37. end
  38. --------------------------------------------------------------------------------
  39. --// Create ScreenGui + Buttons + Labels
  40. --------------------------------------------------------------------------------
  41. local screenGui = Instance.new("ScreenGui")
  42. screenGui.Name = "TaskGui"
  43. screenGui.ResetOnSpawn = false
  44. screenGui.Parent = game:GetService("CoreGui")
  45.  
  46. -- "Do Task" button
  47. local taskButton = Instance.new("TextButton")
  48. taskButton.Size = UDim2.new(0, 150, 0, 35)        
  49. taskButton.Position = UDim2.new(0, 10, 0, 120)  
  50. taskButton.Text = "Do Task"
  51. taskButton.Visible = false
  52. taskButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  53. taskButton.TextColor3 = Color3.new(1, 1, 1)
  54. taskButton.Font = Enum.Font.SourceSansBold
  55. taskButton.TextScaled = true
  56. taskButton.Parent = screenGui
  57.  
  58. -- "Kill" button
  59. local killButton = Instance.new("TextButton")
  60. killButton.Size = UDim2.new(0, 150, 0, 35)      
  61. killButton.Position = UDim2.new(0, 10, 0, 165)  
  62. killButton.Text = "Kill"
  63. killButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  64. killButton.TextColor3 = Color3.new(1, 1, 1)
  65. killButton.Font = Enum.Font.SourceSansBold
  66. killButton.TextScaled = true
  67. killButton.Parent = screenGui
  68.  
  69. -- Task prompt Label (also reused for error/status messages at the top)
  70. local taskPromptLabel = Instance.new("TextLabel")
  71. taskPromptLabel.Size = UDim2.new(1, 0, 0, 30)
  72. taskPromptLabel.Position = UDim2.new(0, 0, 0, 0)
  73. taskPromptLabel.BackgroundTransparency = 0.5
  74. taskPromptLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  75. taskPromptLabel.TextColor3 = Color3.new(1, 1, 1)
  76. taskPromptLabel.Font = Enum.Font.SourceSansBold
  77. taskPromptLabel.TextScaled = true
  78. taskPromptLabel.Text = ""
  79. taskPromptLabel.Visible = false
  80. taskPromptLabel.Parent = screenGui
  81.  
  82. -- Watermark (rainbow)
  83. local watermark = Instance.new("TextLabel")
  84. watermark.Size = UDim2.new(0, 200, 0, 50)
  85. watermark.Position = UDim2.new(1, -210, 1, -60)
  86. watermark.BackgroundTransparency = 1
  87. watermark.Text = "KZscript"
  88. watermark.TextTransparency = 0.65
  89. watermark.TextScaled = true
  90. watermark.Font = Enum.Font.SourceSansBold
  91. watermark.Parent = screenGui
  92.  
  93. local uiGradient = Instance.new("UIGradient")
  94. uiGradient.Parent = watermark
  95. uiGradient.Color = ColorSequence.new{
  96.     ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
  97.     ColorSequenceKeypoint.new(0.17, Color3.fromRGB(255, 165, 0)),
  98.     ColorSequenceKeypoint.new(0.33, Color3.fromRGB(255, 255, 0)),
  99.     ColorSequenceKeypoint.new(0.5, Color3.fromRGB(0, 255, 0)),
  100.     ColorSequenceKeypoint.new(0.67, Color3.fromRGB(0, 0, 255)),
  101.     ColorSequenceKeypoint.new(0.83, Color3.fromRGB(75, 0, 130)),
  102.     ColorSequenceKeypoint.new(1, Color3.fromRGB(238, 130, 238))
  103. }
  104. uiGradient.Rotation = 0
  105.  
  106. --------------------------------------------------------------------------------
  107. --// Helper: Show a quick message at the top
  108. --------------------------------------------------------------------------------
  109. local function showMessage(msg, duration)
  110.     taskPromptLabel.Text = msg
  111.     taskPromptLabel.Visible = true
  112.     task.wait(duration or 2)
  113.     taskPromptLabel.Visible = false
  114. end
  115.  
  116. --------------------------------------------------------------------------------
  117. --// Animate the Watermark Gradient
  118. --------------------------------------------------------------------------------
  119. local function animateGradient()
  120.     local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
  121.     local goal = { Rotation = 360 }
  122.     local tween = TweenService:Create(uiGradient, tweenInfo, goal)
  123.     tween:Play()
  124. end
  125. animateGradient()
  126.  
  127. --------------------------------------------------------------------------------
  128. --// Update "Do Task" Button Visibility
  129. --------------------------------------------------------------------------------
  130. local function updateButtonVisibility()
  131.     -- Visible only if on the "Criminals" team
  132.     if LocalPlayer.Team and LocalPlayer.Team.Name == "Criminals" then
  133.         taskButton.Visible = true
  134.     else
  135.         taskButton.Visible = false
  136.     end
  137. end
  138. bindConnection(LocalPlayer:GetPropertyChangedSignal("Team"), updateButtonVisibility)
  139. updateButtonVisibility()
  140.  
  141. --------------------------------------------------------------------------------
  142. --// Do Task Logic
  143. --------------------------------------------------------------------------------
  144. local function executeTask()
  145.     local playerModel = Workspace:FindFirstChild(LocalPlayer.Name)
  146.     if not playerModel then
  147.         warn("Player model not found in Workspace!")
  148.         return
  149.     end
  150.  
  151.     local oldTaskName = playerModel:GetAttribute("TaskName")
  152.     if not oldTaskName or oldTaskName == "" or oldTaskName:match("^%s*$") then
  153.         showMessage("No Tasks Wait", 3)
  154.         return
  155.     end
  156.  
  157.     -- Attempt to find the ProximityPrompt
  158.     local promptFound
  159.     local partToLookAt -- BasePart to aim the camera at
  160.     for _, folder in ipairs(Workspace:GetChildren()) do
  161.         if folder:IsA("Folder") then
  162.             local tasksFolder = folder:FindFirstChild("Tasks")
  163.             if tasksFolder then
  164.                 local taskModel = tasksFolder:FindFirstChild(oldTaskName)
  165.                 if taskModel and taskModel:IsA("Model") then
  166.                     local prompt = taskModel:FindFirstChildOfClass("ProximityPrompt")
  167.                     if prompt then
  168.                         promptFound = prompt
  169.  
  170.                         -- If there's a "Hitbox" inside the model, use that
  171.                         local hitbox = taskModel:FindFirstChild("Hitbox")
  172.                         if hitbox and hitbox:IsA("BasePart") then
  173.                             partToLookAt = hitbox
  174.                         -- Otherwise use PrimaryPart if set
  175.                         elseif taskModel.PrimaryPart then
  176.                             partToLookAt = taskModel.PrimaryPart
  177.                         end
  178.  
  179.                         break
  180.                     end
  181.                 end
  182.             end
  183.         end
  184.     end
  185.  
  186.     -- We'll track when the TaskName changes or becomes empty
  187.     local done = false
  188.     local taskCheckConnection
  189.     taskCheckConnection = bindConnection(playerModel:GetAttributeChangedSignal("TaskName"), function()
  190.         local newTaskName = playerModel:GetAttribute("TaskName")
  191.         if (newTaskName ~= oldTaskName and newTaskName ~= nil)
  192.            or newTaskName == ""
  193.            or newTaskName == " " then
  194.             done = true
  195.         end
  196.     end)
  197.  
  198.     local function cleanupTaskCheck()
  199.         if taskCheckConnection and taskCheckConnection.Connected then
  200.             taskCheckConnection:Disconnect()
  201.         end
  202.     end
  203.  
  204.     if promptFound then
  205.         -- 1) Point the camera at the found part (if any)
  206.         local camera = Workspace.CurrentCamera
  207.         local char = LocalPlayer.Character
  208.         if char and char:FindFirstChild("Humanoid") then
  209.             camera.CameraSubject = char:FindFirstChild("Humanoid")
  210.         end
  211.  
  212.         if partToLookAt and partToLookAt:IsA("BasePart") then
  213.             local camPos = camera.CFrame.Position
  214.             local lookAt = partToLookAt.Position
  215.             camera.CFrame = CFrame.new(camPos, lookAt)
  216.         end
  217.  
  218.         -- 2) Set prompt properties
  219.         promptFound.HoldDuration = 0
  220.         promptFound.MaxActivationDistance = 1000
  221.  
  222.         -- 3) Attempt to manually hold E in a loop for up to 5 seconds
  223.         local startTime = os.clock()
  224.         while (os.clock() - startTime) < 5 and not done do
  225.             for _, folder in ipairs(Workspace:GetChildren()) do
  226.                 if folder:IsA("Folder") then
  227.                     local tasksFolder = folder:FindFirstChild("Tasks")
  228.                     if tasksFolder then
  229.                         local taskModel = tasksFolder:FindFirstChild(oldTaskName)
  230.                         if taskModel and taskModel:IsA("Model") then
  231.                             local prompt = taskModel:FindFirstChildOfClass("ProximityPrompt")
  232.                                 if prompt then
  233.                                     fireproximityprompt(prompt)
  234.                                 end
  235.                         end
  236.                     end
  237.                 end
  238.             end        
  239.             task.wait(0.5)
  240.  
  241.             if done then break end
  242.             task.wait(0.1)
  243.         end
  244.  
  245.         if done then
  246.             showMessage("Task Done!", 2)
  247.         else
  248.             taskPromptLabel.Text = "Try Manually - Look To Task Direction and Click E"
  249.             taskPromptLabel.Visible = true
  250.             task.wait(3)
  251.             taskPromptLabel.Visible = false
  252.         end
  253.  
  254.         cleanupTaskCheck()
  255.     else
  256.         showMessage("Couldn't find prompt for this task", 3)
  257.         cleanupTaskCheck()
  258.     end
  259. end
  260. taskButton.MouseButton1Click:Connect(executeTask)
  261.  
  262. --------------------------------------------------------------------------------
  263. --// Billboard Creation (Team Labels / ESP)
  264. --------------------------------------------------------------------------------
  265. -- Real players have "TradeProximityPrompt" in their HRP
  266. local function createOrUpdateBillboard(player)
  267.     if not _G.ensureloop then return end
  268.  
  269.     local char = player.Character
  270.     if not char then return end
  271.  
  272.     local rootPart = char:FindFirstChild("HumanoidRootPart")
  273.     if not rootPart then
  274.         return
  275.     end
  276.  
  277.     -- If there's NO "TradeProximityPrompt", skip => NPC
  278.     if not rootPart:FindFirstChild("TradeProximityPrompt") then
  279.         return
  280.     end
  281.  
  282.     local head = char:FindFirstChild("Head")
  283.     if not head then
  284.         return
  285.     end
  286.  
  287.     local billboardGui = head:FindFirstChild("PlayerBillboard")
  288.     if not billboardGui then
  289.         billboardGui = Instance.new("BillboardGui")
  290.         billboardGui.Name = "PlayerBillboard"
  291.         billboardGui.Size = UDim2.new(0, 200, 0, 50)
  292.         billboardGui.StudsOffset = Vector3.new(0, 2, 0)
  293.         billboardGui.AlwaysOnTop = true
  294.         billboardGui.LightInfluence = 0
  295.         billboardGui.MaxDistance = 200
  296.  
  297.         local textLabel = Instance.new("TextLabel")
  298.         textLabel.Size = UDim2.new(1, 0, 1, 0)
  299.         textLabel.BackgroundTransparency = 1
  300.         textLabel.Text = "PLAYER!!"
  301.         textLabel.TextColor3 = Color3.new(1, 1, 1)
  302.         textLabel.TextScaled = true
  303.         textLabel.Font = Enum.Font.SourceSansBold
  304.         textLabel.Parent = billboardGui
  305.  
  306.         billboardGui.Parent = head
  307.     end
  308.  
  309.     local textLabel = billboardGui:FindFirstChildOfClass("TextLabel")
  310.     local function updateTeamText()
  311.         if not _G.ensureloop then return end
  312.         if player.Team == Teams:FindFirstChild("Sheriffs") then
  313.             textLabel.Text = "Sheriff"
  314.             textLabel.TextColor3 = Color3.fromRGB(0, 0, 255)
  315.         elseif player.Team == Teams:FindFirstChild("Criminals") then
  316.             textLabel.Text = "Criminal"
  317.             textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
  318.         else
  319.             textLabel.Text = "Neutral"
  320.             textLabel.TextColor3 = Color3.new(1, 1, 1)
  321.         end
  322.     end
  323.  
  324.     -- Update label whenever their team changes
  325.     bindConnection(player:GetPropertyChangedSignal("Team"), updateTeamText)
  326.     updateTeamText()
  327. end
  328.  
  329. --------------------------------------------------------------------------------
  330. --// Ensure Billboards for All Players
  331. --------------------------------------------------------------------------------
  332. local function ensureBillboards()
  333.     for _, player in ipairs(Players:GetPlayers()) do
  334.         createOrUpdateBillboard(player)
  335.     end
  336. end
  337. ensureBillboards()
  338.  
  339. local billboardCoroutine = coroutine.create(function()
  340.     while _G.ensureloop do
  341.         ensureBillboards()
  342.         task.wait(5)
  343.     end
  344. end)
  345. coroutine.resume(billboardCoroutine)
  346.  
  347. bindConnection(Players.PlayerAdded, function(player)
  348.     bindConnection(player.CharacterAdded, function()
  349.         createOrUpdateBillboard(player)
  350.     end)
  351. end)
  352.  
  353. --------------------------------------------------------------------------------
  354. --// Wait for Target (Character + HumanoidRootPart)
  355. --------------------------------------------------------------------------------
  356. local function waitForCharacterAndHRP(plr, timeout)
  357.     local startTime = os.clock()
  358.     while not plr.Character and (os.clock() - startTime) < timeout do
  359.         task.wait(0.1)
  360.     end
  361.     local char = plr.Character
  362.     if not char then
  363.         return nil
  364.     end
  365.  
  366.     startTime = os.clock()
  367.     while not char:FindFirstChild("HumanoidRootPart") and (os.clock() - startTime) < timeout do
  368.         task.wait(0.1)
  369.     end
  370.     return char:FindFirstChild("HumanoidRootPart")
  371. end
  372.  
  373. --------------------------------------------------------------------------------
  374. --// Kill All Changes
  375. --------------------------------------------------------------------------------
  376. local function killAllChanges()
  377.     _G.ensureloop = false
  378.     for _, c in ipairs(connections) do
  379.         if c.Connected then
  380.             c:Disconnect()
  381.         end
  382.     end
  383.     staminaActive = false
  384.     stamina.Value = 6
  385.     -- Remove ScreenGui
  386.     if screenGui then
  387.         screenGui:Destroy()
  388.     end
  389.  
  390.     -- Remove Billboards
  391.     for _, player in ipairs(Players:GetPlayers()) do
  392.         local c = player.Character
  393.         if c and c:FindFirstChild("Head") then
  394.             local billboard = c.Head:FindFirstChild("PlayerBillboard")
  395.             if billboard then
  396.                 billboard:Destroy()
  397.             end
  398.         end
  399.     end
  400.  
  401.     if watermark and watermark.Parent then
  402.         watermark:Destroy()
  403.     end
  404. end
  405. killButton.MouseButton1Click:Connect(killAllChanges)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement