generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Ideas on how to move an object.

Previous Thread :: Next Thread 
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 02:53 PM
I can do the scripting for WaSD/Arrows, but how would I move an object in Workspace called "Part".

BEFORE YOU SAY CFRAME : While the object is moving, it was to be able to interact with laws of physics and be collide-able with other objects, CFrame ignores both. The part has to interact with physics and collide with other objects.

So what would be your way/idea of how to do so?
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 02:55 PM
Use BodyVelocity or etc.
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 03:06 PM
Ah. um, next question how would you make it move in direct the part is "looking"?

here's my script so far

local part = game.Workspace.Part
local pos = Instance.new("BodyVelocity")

function onKeyDown(key)
if key:lower() == "w" then
pos.Parent = part
moving = true
while moving== true do
pos.velocity = blank, no idea what would go here.
wait(.001)
end

mouse.KeyDown:connect(onKeyDown)
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 03:10 PM
Well what exactly are you trying to script?
Like; will you be first-person viewing the object?
Report Abuse
sloomingbla is not online. sloomingbla
Joined: 28 Jun 2008
Total Posts: 1109
23 May 2013 03:12 PM
Use bodyposition and set its position to the lookvector of the part * 2

( ._.)|) ( D:)
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
23 May 2013 03:17 PM
Or you can use bodyvelocity, which I like using a lot more and find it easier.
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 03:21 PM

@KanataIzumi7, not necessary I'll most be viewing it in 3rd person to make sure it moves. And I'm trying to make a part in workspace move when you press W, but the part has to interact with collision.

@sloomingbla
So changing it to BodyPosition I made this :

pos.position = pos.position.lookVector * 2

I'm not very good with BodyPosition, so I really don't understand the lookVector part of it... So I know the snippet above isn't going to work.
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 03:23 PM
So just move the brick forward in the direction it's facing, or in the direction the player is moving forward in?

If the first, then using what the others mentioned would work?
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 03:32 PM
the first, but my only problem is.. I can't figure out the lookVector for BodyPosition and BodyVelocitys..
Report Abuse
KanataIzumi7 is not online. KanataIzumi7
Joined: 08 May 2011
Total Posts: 949
23 May 2013 03:44 PM
CFrame.lookVector returns the direction it's look at, so you could use that.
Report Abuse
sloomingbla is not online. sloomingbla
Joined: 28 Jun 2008
Total Posts: 1109
23 May 2013 03:59 PM
^ that

do pos = part.CFrame.lookVector * 2

( ._.)|) ( D:)
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
23 May 2013 04:01 PM
bodyvelocity.velocity = part.CFrame.unit*(a certain number; the speed)

Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 04:17 PM
@TheAwesomenessDude

function onKeyDown(key)
if key:lower() == "w" then
pos.Parent = game.Workspace.Part
moving = true
while moving == true do
local part = game.Workspace.Part
direction = game.Workspace.Part.CFrame.lookVector * 9999 -- I think I need this..
pos.velocity = part.CFrame.unit*(direction)
wait(.001)
end
end

16:14:57.072 - Unit is not a valid member



Report Abuse
sloomingbla is not online. sloomingbla
Joined: 28 Jun 2008
Total Posts: 1109
23 May 2013 04:18 PM
velocity is hard to work with, atleast for me.

trust me, use bodyposition :3

or just use moveto on a humanoid?

( ._.)|) ( D:)
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 04:28 PM
MoveTo() is toooo glitchy.

function onKeyDown(key)
if key:lower() == "w" then
local part = game.Workspace.Part
pos.Parent = game.Workspace.Part -- Line 41
driving = true
while driving == true do
pos = part.CFrame.lookVector * 2
wait(.001)
end
end

Why? 16:26:39.046 - Parent cannot be assigned to
16:26:39.046 - Script "Players.Player1.Backpack.test.LocalScript", Line 41
16:26:39.047 - stack end

Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 04:52 PM
/\
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
23 May 2013 05:00 PM
It just says the line #... no error like "eof", etc?

Disregard females, acquire currency.
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 05:15 PM
oh, add an extra end.
Sorry I didn't copy it..
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
23 May 2013 05:46 PM
I don't think the ends are your issue, I was just wondering what random error the output gave.

Disregard females, acquire currency.
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 06:04 PM
function onKeyDown(key)
if key:lower() == "w" then
pos.Parent = game.Workspace.Part
--stay.Parent = game.Workspace.Part
driving = true
while driving == true do
local part = game.Workspace.Part
direction = game.Workspace.Part.CFrame.lookVector * 9999
pos = part.CFrame.lookVector * 2
wait(.001)
end
end
end

run it, bam you get the output I posted above.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
23 May 2013 06:04 PM
Literally just the line number? o_O

I don't think you'll get much help without some kind of output.. I hate the output sometimes D:

Disregard females, acquire currency.
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
23 May 2013 06:09 PM
What's pos o-o?
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 06:12 PM
ugh...

FULL SCRIPT :

local pos = Instance.new("BodyPosition")
local hopper = script.Parent
local mouse = plr:GetMouse()
local driving = false

function onKeyDown(key)
if key:lower() == "w" then
local part = game.Workspace.Part
pos.Parent = game.Workspace.Part -- Line 41
driving = true
while driving == true do
pos = part.CFrame.lookVector * 2
wait(.001)
end
end

hopper.Selected:connect(function()
mouse.KeyDown:connect(onKeyDown)
mouse.KeyUp:connect(onKeyUp)
end)


plr.Character.Humanoid.Changed:connect(function()
plr.Character.Humanoid.Jump = false
plr.Character.Humanoid.Sit = true
end)

Output..
16:26:39.046 - Parent cannot be assigned to
16:26:39.046 - Script "Players.Player1.Backpack.test.LocalScript", Line 41
16:26:39.047 - stack end
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
23 May 2013 06:19 PM
Try this

local pos = Instance.new("BodyPosition")
local hopper = script.Parent
local mouse = plr:GetMouse()
local driving = false

function onKeyDown(key)
if key:lower() == "w" then
local part = game.Workspace.Part
pos.Parent = part -- Line 41
driving = true
while driving == true do
pos = part.CFrame.lookVector * 2
wait(.001)
end
end

Disregard females, acquire currency.
Report Abuse
GuestCapone is online. GuestCapone
Joined: 19 Oct 2012
Total Posts: 1928
23 May 2013 06:45 PM
Doesn't work..
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image