Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local mouse = game.Players.LocalPlayer:GetMouse()
- local tool = Instance.new("Tool")
- tool.RequiresHandle = false
- tool.Name = "tpTool"
- tool.Activated:connect(function()
- local pos = mouse.Hit + Vector3.new(0, 2.5, 0)
- pos = CFrame.new(pos.X, pos.Y, pos.Z)
- game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = pos
- end)
- tool.Parent = game.Players.LocalPlayer.Backpack
- local attacks = replicatedStorage:WaitForChild("Attacks")
- local spaceRipper = attacks:WaitForChild("SpaceRipper")
- local localPlayer = players.LocalPlayer
- local animationId = "rbxassetid://5901872109"
- local animator = localPlayer.Character:WaitForChild("Humanoid"):FindFirstChildOfClass("Animator") or Instance.new("Animator", localPlayer.Character:WaitForChild("Humanoid"))
- local screenGui = Instance.new("ScreenGui", localPlayer.PlayerGui)
- local button = Instance.new("TextButton", screenGui)
- button.Size = UDim2.new(0, 100, 0, 50)
- button.Position = UDim2.new(0.9, 0, 0.9, 0)
- button.Text = "Space Ripper"
- button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- local function getClosestPlayer()
- local closestPlayer = nil
- local closestDistance = math.huge
- for _, player in ipairs(players:GetPlayers()) do
- if player ~= localPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
- local distance = (localPlayer.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).magnitude
- if distance < closestDistance then
- closestDistance = distance
- closestPlayer = player
- end
- end
- end
- return closestPlayer
- end
- local function predictTargetPosition(target, speed)
- local targetPosition = target.Character.HumanoidRootPart.Position
- local targetVelocity = target.Character.HumanoidRootPart.Velocity
- local predictedPosition = targetPosition + targetVelocity * speed
- return predictedPosition
- end
- local function onButtonClick()
- local closestPlayer = getClosestPlayer()
- if closestPlayer then
- local animation = Instance.new("Animation")
- animation.AnimationId = animationId
- local animationTrack = animator:LoadAnimation(animation)
- animationTrack:Play()
- wait(0.3)
- local targetPosition = predictTargetPosition(closestPlayer, 0.4)
- spaceRipper:FireServer(targetPosition, closestPlayer.Name)
- else
- warn("no nearby player.")
- end
- end
- button.MouseButton1Click:Connect(onButtonClick)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement