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

How to move the position of your character?

Hello everyone, good morning (or afternoon if your in a different time zone) and today I have a serious question that came up in my head.

Literally, how do you move the position of your character on the X,Y, and Z axis similar to how you would do it for a brick?

Lately I have been going into the keyDown stuff, and even though im a complete novice towards scripting and probably shouldn't be doing this kind of advanced stuff, I like to experiment.

My ultimate goal is to make a script that once your press a certain key on the keyboard, it sends your character moving in different positions, as you are about to see in the code I will show you.

player = game.Players.LocalPlayer

tool = script.Parent

tool.Equipped:connect(function(mouse)
	mouse.KeyDown:connect(function(key)
		if key == "h" then
			print("You pressed h")
		else
			print("Try again and press h")
		end
	end)
end)

That was my first attempt at doing anything with keyDown, and it is pretty basic.

3 answers

You Cframe the character to a new area.

6 comments

0

Use something like this

0

torso.CFrame = CFrame.new(-432, 2.2, 64)

0

So how would I be able to get the current position of the character, and add that one on? So that way it won't simply go to the position I put, and add on from the one the character is already at?

0

That question is for someone more advanced than me... Sorry.

0

Since it's a tool, and I want for it to be local would it be someting like game.Workspace.Players.LocalPlayer.torso.CFrame = CFrame.new(-432, 2.2, 64)? Because I am basically confused on moving the character itself.

0

Sorry, the question is beyond my knowledge... I wish I could help beyond what I said.

player = game.Players.LocalPlayer
local mouse = player:GetMouse()
tool = script.Parent
tool.Equipped:connect(function()
    mouse.KeyDown:connect(function(key)
        if key == "h" then
	player.Character:MoveTo(mouse.Hit)
            print("You pressed h")
        else
            print("Try again and press h")
        end
    end)
end)

I believe that's how it goes... Maybe not... Hope this helped, I'm sort of new to key's as well however I'm familiar with the moving of a character.

4 comments

0

Doesn't seem to work since the output is telling me Position is not a valid member, also it looks like what you gave me moves the character when I press "h" wherever my mouse is?

0

Yes, change on line 07 "mouse.Hit.Position" to "mouse.Hit.CFrame" I know it's CFrame or Position... Something... e.e

0

CFrame is not a valid member either xD

0

Wow... I feel dumb, um... Try just Hit... e.e Maybe that works?

by W A S D no duh

1 comment

0

i meant how to move the position of the whole character on the different axis.

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