✓ Accepted answer
Using :GetMouse() in a Local Script, you can get the Player's Mouse. In this instance, we can use Mouse.Hit and Mouse.Target. Mouse.Hit returns the CFrame of the Cursor. In simpler terms, where the Mouse is pointing. Mouse.Target returns the object the object the Mouse is pointing to. In this instance, we want to use Mouse.Hit to get the CFrame of the Mouse. When we do that, we can set our HumanoidRootPart's CFrame to the CFrame of the Mouse. It would look something like this.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local UserInputService = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.Q and Mouse.Hit then
local MouseCFrame = Mouse.Hit
HumanoidRootPart.CFrame = MouseCFrame
end
end)
3 comments
I can see your new so im gonna say it first to you. this isnt a request site JoyfulPhoenix may of answered but just remember this isnt a request site
Yes, Ik, I never asked for the whole script.
Look things up before you ask on here. Or check out the Dev Forum.