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

Please help me complete my MoveTo script for a sword? is this concise enough for you bot?

I'm making a sword where when you click your WalkSpeed is set to 0, but I still want the player to walk forwards a little to go with the attack animation. I don't know if MoveTo is the best option cause I'm a noobie scripter. I've considered BodyForce, but MoveTo sounds like the better option.

local h = script.Parent.Parent.Humanoid

function onActivated()
  h:MoveTo(Vector3.new(6,0,0)

script.Parent.Activated:connect(onActivated)

I'm just trying to get the player to move forward 6 studs when they click. (i guessed on the x,y,z I'll trial and error that later)

I gave the script pretty much every idea I had, which was very few, so any help/ideas are very much appreciated!

7 comments

0

first time having trouble with the title... wasn't concise yet specific enough apparently..

0

this script is intended for R6 if that's important btw!

0

you are missing a parenthesis on line 4, it should be h:MoveTo(Vector3.new(6,0,0))

0

also, this moves them to the position 6,0,0 every time, and it doesn't take the player's current position into account

0

thank you! I'll do some searching on getting the players position and what not

0

You can't use MoveTo() if the walkspeed is set to 0.

0

I'll just set the walkspeed to 4 or something. It shouldn't effect what my end goal is. TY

1 answer

EDIT:

local h = script.Parent.Parent.Humanoid

function onActivated()
	h.Parent.Torso.Velocity = h.Parent.Torso.CFrame.LookVector * 100 
            -- use a value other than 100 if you want more or less boost 
            -- if you are using R15 character you need some other part of the body than Torso
            -- I have not tested this, again tell me if it doesn't work :D
	h.WalkSpeed = 0
	wait (1)
	-- start moving again
	h.WalkSpeed = 16
script.Parent.Activated:connect(onActivated)

Sorry for the delay :/

9 comments

0

Just tell me if I got anything wrong and I will try and fix it.

0

This is the method I would use, but I'mt trying to make it so the player HAS to move forward once they've clicked.

0

oh... sorry

0

Don't worry!! This is my backup plan for sure! B)

0

I just got it :D

0

Use CFrame.Lookvector!

0

If this works please tell me and accept my answer.

0

The new script probably moves him too far, just decrease the value

0

1 year later and I accidentally found ur edited version. I tried inserting it into my current script and it didn't work unfortunately but I appreciate you trying. Going to use body velocity.

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