Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make it so that if I press a button I can teleport to my mouse location?

I've tried lots of scripts but I'm an imbecile.

2 answers

Create a click event, upon firing change the CFrame of the client's HumanoidRootPart to the client's Mouse.Hit

3 comments

0

He said whenever one clicks a button though.

0

Exactly, that's why I said "Create a click event".

0

Click events only works for mouse events. With UserInputService you can use all other keyboards buttons as well as the mouse.He didn't specify mouse button so I like to keep the options open.

local player = game.Players.LocalPlayer local Character = player.Character or player.CharacterAdded:Wait() local Mouse = player:GetMouse() local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(Key) if Key.KeyCode == Enum.KeyCode.T then Character:SetPrimaryPartCFrame(Mouse.Hit) end end)

This discussion is preserved as it was. New answers, comments, and votes are closed.