I am making a game in roblox and a part of what I am trying to do is find a player who pressed a keybind localy and find the players position(I only need help with finding the players position not the keybind)
I tried to search online but i didnt find a solution to my problem
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.G then
_G.MalevolentShire = true
end
end)
I am making a game in roblox and a part of what I am trying to do is find a player who pressed a keybind localy and find the players position(I only need help with finding the players position not the keybind)
I tried to search online but i didnt find a solution to my problem
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.G then
_G.MalevolentShire = true
end
end)
Share
Improve this question
asked Mar 8 at 13:23
user29931871user29931871
11 silver badge
2 Answers
Reset to default 1Every player has an invisible part located by their torso called HumanoidRootPart, that can be used as an inner hitbox or to track the player's position. To access it on a LocalScript, one can use Game.Players.LocalPlayer.Character.HumanoidRootPart
then just get the position like on a normal part.
Since this is a LocalScript, you can use game.Players.LocalPlayer.Character.HumanoidRootPart.Position
to get the Vector3 of the player's character. If you want to get the CFrame of the player's character, use game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
. Example:
print(game.Players.LocalPlayer.Character.HumanoidRootPart.Position) --> 0, 5, 0 (example value)
-- To get rotation:
print(game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.Rotation) --> 0, 0, 0 (example value)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744895134a4599649.html
评论列表(0条)