Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create the tool
- local tool = Instance.new("Tool")
- tool.Name = "TELEPORT TOOL"
- tool.RequiresHandle = false
- tool.ToolTip = "Teleport with clicking on the ground"
- tool.Parent = game.Players.LocalPlayer.Backpack
- -- Handle Mouse Click
- tool.Activated:Connect(function()
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- -- Wait for a click
- mouse.Button1Down:Connect(function()
- if not tool.Enabled then return end -- Ensure the tool is enabled
- tool.Enabled = false -- Disable temporarily to avoid spamming
- local target = mouse.Hit.Position -- Get the position of the click
- -- Teleport the character to the clicked position
- if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
- player.Character.HumanoidRootPart.CFrame = CFrame.new(target + Vector3.new(0, 3, 0)) -- Offset slightly above ground
- end
- -- Re-enable the tool after a short delay
- task.wait(0.2)
- tool.Enabled = true
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement