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

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

Asked by
Kimuyo 13
6 years ago

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!

0
first time having trouble with the title... wasn't concise yet specific enough apparently.. Kimuyo 13 — 6y
0
this script is intended for R6 if that's important btw! Kimuyo 13 — 6y
0
you are missing a parenthesis on line 4, it should be h:MoveTo(Vector3.new(6,0,0)) theking48989987 2147 — 6y
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 theking48989987 2147 — 6y
View all comments (3 more)
0
thank you! I'll do some searching on getting the players position and what not Kimuyo 13 — 6y
0
You can't use MoveTo() if the walkspeed is set to 0. Xx_XSanderPlayXx 160 — 6y
0
I'll just set the walkspeed to 4 or something. It shouldn't effect what my end goal is. TY Kimuyo 13 — 6y

1 answer

Log in to vote
0
Answered by
OBenjOne 190
6 years ago
Edited 6 years ago

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 :/

0
Just tell me if I got anything wrong and I will try and fix it. OBenjOne 190 — 6y
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. Kimuyo 13 — 6y
0
oh... sorry OBenjOne 190 — 6y
0
Don't worry!! This is my backup plan for sure! B) Kimuyo 13 — 6y
View all comments (5 more)
0
I just got it :D OBenjOne 190 — 6y
0
Use CFrame.Lookvector! OBenjOne 190 — 6y
0
If this works please tell me and accept my answer. OBenjOne 190 — 6y
0
The new script probably moves him too far, just decrease the value OBenjOne 190 — 6y
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. Kimuyo 13 — 4y
Ad

Answer this question