Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Character
- local targetNPC
- local noclipEnabled = false
- -- Customizable parameters
- local delay = 0.5 -- Delay between teleports (in seconds)
- local offset = Vector3.new(0, 9, 0) -- Vertical offset above the NPC
- local noMobWaitTime = 3 -- Wait time (in seconds) if no mobs are found
- -- Remote Event setup
- local dataRemoteEvent = game:GetService("ReplicatedStorage").dataRemoteEvent
- local retryVote = LocalPlayer.PlayerGui.RetryVote
- local revivePrompt = LocalPlayer.PlayerGui.RevivePrompt
- -- Function to toggle noclip
- local function toggleNoclip()
- noclipEnabled = not noclipEnabled
- if Character and Character.Humanoid then
- Character.Humanoid:ChangeState(noclipEnabled and 11 or Enum.HumanoidStateType.Running)
- end
- end
- -- Connect noclip toggle to the "o" key
- game:GetService("UserInputService").InputBegan:Connect(function(input, processed)
- if not processed and input.KeyCode == Enum.KeyCode.O then
- toggleNoclip()
- end
- end)
- local function findNearestNPC()
- local nearestNPC = nil
- local nearestDistance = math.huge
- Character = LocalPlayer.Character
- if not Character or not Character.HumanoidRootPart then return end
- for _, folder in ipairs(workspace:GetChildren()) do
- if folder:IsA("Folder") then
- for _, child in ipairs(folder:GetChildren()) do
- if child:FindFirstChild("enemyFolder") then
- for _, npc in ipairs(child.enemyFolder:GetChildren()) do
- if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
- local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
- if distance < nearestDistance then
- nearestDistance = distance
- nearestNPC = npc
- end
- end
- end
- end
- end
- end
- end
- return nearestNPC
- end
- local function stayOnTopOfNPC()
- if not targetNPC or not targetNPC.Parent or not targetNPC:FindFirstChild("HumanoidRootPart") then
- targetNPC = findNearestNPC()
- end
- Character = LocalPlayer.Character
- if Character and Character:FindFirstChild("HumanoidRootPart") and targetNPC and targetNPC:FindFirstChild("HumanoidRootPart") then
- local npcPosition = targetNPC.HumanoidRootPart.Position
- local lookVector = (npcPosition - Character.HumanoidRootPart.Position).Unit
- local cframe = CFrame.new(npcPosition + offset, npcPosition)
- Character.HumanoidRootPart.CFrame = cframe
- end
- end
- -- CharacterAdded Connection
- LocalPlayer.CharacterAdded:Connect(function(newCharacter)
- Character = newCharacter
- targetNPC = nil
- wait(1)
- end)
- local lastTeleportTime = 0
- local lastMobCheckTime = 0
- local args = {
- [1] = {
- [1] = {
- ["\3"] = "vote",
- ["vote"] = true
- },
- [2] = "."
- }
- }
- game:GetService("RunService").Heartbeat:Connect(function()
- stayOnTopOfNPC()
- if noclipEnabled and Character and Character.Humanoid then
- Character.Humanoid:ChangeState(11)
- end
- local currentTime = tick()
- if currentTime - lastTeleportTime >= delay then
- lastTeleportTime = currentTime
- targetNPC = findNearestNPC()
- if targetNPC then -- Check if a mob was found
- lastMobCheckTime = currentTime -- Reset timer if mob found
- -- Fire remote events
- if retryVote and retryVote.Enabled then
- dataRemoteEvent:FireServer(unpack(args))
- end
- if revivePrompt and revivePrompt.Enabled then
- print("RevivePrompt is enabled. Add your revive logic here.")
- end
- elseif currentTime - lastMobCheckTime >= noMobWaitTime then
- print("No mobs found. Waiting...")
- lastMobCheckTime = currentTime -- Keep waiting until a mob is found
- end
- end
- end)
- -- Initialize
- targetNPC = findNearestNPC()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement