Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

2 answers

Log in to vote
0
Answered by
Upbolt 20
4 years ago

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

0
He said whenever one clicks a button though. noammao 294 — 4y
0
Exactly, that's why I said "Create a click event". Upbolt 20 — 4y
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. noammao 294 — 4y
Ad
Log in to vote
0
Answered by
noammao 294 Moderation Voter
4 years ago

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)

Answer this question