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 » Scripters
Home Search
 

Re: Problem with simple rotation script

Previous Thread :: Next Thread 
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 12:00 AM
There are no errors with this script, it's a regular script in a part in the workspace, and it's not right.


up=true
part=script.Parent
rot=part.Rotation
pos=part.Position
if up then
wait(2)
up=false
else
wait(2)
up=true
end

while true do
wait()
rot=rot+Vector3.new(0,3,0)
if up then
pos=pos+Vector3.new(0,.1,0)
wait()
else
pos=pos-Vector3.new(0,.1,0)
wait()
end
end


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 12:15 AM
nevermind, apparently lerp escaped from my mind. :P


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 12:34 AM
bump, I'm too dumb for lerp.


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 12:43 AM
I'm not paying for your taxi. (bump)


y-y-you too...
Report Abuse
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
28 Feb 2016 01:43 AM
What is happening and what is your expectation?


Join here to see things I made_ http://www.roblox.com/My/Groups.aspx?gid=1147121
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 02:47 PM
I just want to rotate a part in the workspace continuously clockwise, and have it move up and down. (like a hologram)

so far I've tried:

local part=script.Parent
local pos1=part:WaitForChild("pos1") -- this part is the starting point.
local pos2=part:WaitForChild("pos2") -- this part is 2 studs above the starting point and rotated 180 degrees.

while wait() do
for i=0,1,.01 do
part.CFrame=pos1.CFrame:lerp(pos2.CFrame,i)
wait(.1)
end
for i=0,1,.1 do
part.CFrame=pos2.CFrame:lerp(pos1.CFrame,i)
wait(.1)
end
end

next i tried:
up=true
rs=game:GetService("RunService").RenderStepped
part=script.Parent
rot=part.Rotation
pos=part.Position
if up then
wait(2)
up=false
else
wait(2)
up=true
end

while true do
wait()
rot=rot+Vector3.new(0,3,0)
if up then
pos=pos+Vector3.new(0,.1,0)
wait()
else
pos=pos-Vector3.new(0,.1,0)
wait()
end
end

neither worked. No errors, nothing. the part just stays there like nothing's happening.


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 02:58 PM
Trump... I mean, bump.


y-y-you too...
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Feb 2016 02:58 PM
Just something I made quickly. Try it, if it doesn't work tell me what happens

local p = workspace.Part

partup = {}
for i = 1,8 do
table.insert(partup,p.CFrame*CFrame.new(0,i,0)
wait()
end

spawn(function()
while wait() do
p.CFrame = p.CFrame*CFrame.Angles(1,0,0)
end
end)

local poschange = 1
local subtractchange = false
while wait() do
if poschange <8 and not subtractchange then
poschange = poschange+1
p.CFrame = partup[poschange]
else
substractchange = true
poschange = poschange - 1
p.CFrame = partup[poschange]
if poschange == 1 then
subtractchange = false
end
end
end
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 03:13 PM
Result: https://youtu.be/838T6sKECOc

You can see it's default position at the beginning. it literally just has a seizure and doesn't stop.


y-y-you too...
Report Abuse
DevDays is not online. DevDays
Joined: 16 Dec 2015
Total Posts: 112
28 Feb 2016 03:17 PM
Use BodyForces.

eg: BodyAngularVelocity.


Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 03:20 PM
Awe, I'm going to have to spend my day learning that now? great. I really wish this was easier. xD It's fine.


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 03:28 PM
@DevDays I don't think bodyforces work with an anchored part?


y-y-you too...
Report Abuse
DevDays is not online. DevDays
Joined: 16 Dec 2015
Total Posts: 112
28 Feb 2016 03:32 PM
Obviously they don't.

Unanchor them and run this:

local yourpart = whatever
local floatheight = 5
local BAV = Instance.new("BodyAngularVelocity", yourpart)
BAV.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
BAV.Velocity = Vector3.new(math.random(-100,100),math.random(-100,100),math.random(-100,100))

local bP = Instance.new("BodyPosition", yourpart)
bP.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

local float = coroutine.wrap(function()
while wait() do
for i = -1,1,2 do
for ii = 1,floatheight, 0.1 do
bP.Position = bP.Position+Vector3.new(0,ii,0)
end
end
end
end)

Don't know if it works. I suggest you to improve it if it's needed.


Report Abuse
DevDays is not online. DevDays
Joined: 16 Dec 2015
Total Posts: 112
28 Feb 2016 03:33 PM
local yourpart = whatever
local floatheight = 5
local BAV = Instance.new("BodyAngularVelocity", yourpart)
BAV.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
BAV.Velocity = Vector3.new(math.random(-100,100),math.random(-100,100),math.random(-100,100))

local bP = Instance.new("BodyPosition", yourpart)
bP.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

local float = coroutine.wrap(function()
while wait() do
for i = -1,1,2 do
for ii = 1,floatheight, 0.1 do
bP.Position = bP.Position+Vector3.new(0,ii*i,0)
end
end
end
end)

nvm here you go the fixed one lol


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Feb 2016 03:36 PM
works: local p = script.Parent

partup = {}
for i = 1,8 do
table.insert(partup,p.CFrame*CFrame.new(0,i,0))
wait()
end
spawn(function()
while wait() do
p.CFrame = p.CFrame*CFrame.Angles(0,1,0)
end
end)

local poschange = 1
local subtractchange = false

while wait(.1) do
if poschange < 8 and not subtractchange then
poschange = poschange+1
p.CFrame = partup[poschange]
subtractchange = false
elseif poschange == 8 or subtractchange == true then
substractchange = true
repeat wait()
poschange = poschange - 1
p.CFrame = partup[poschange]
until poschange == 1

end
end

Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Feb 2016 03:36 PM
( you don't have to unanchor the part for mine. )
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 03:37 PM
DevDays' script caused a crash, (idk if I'm doing something wrong or...)

I'll try master's in a sec after I recover my autosave and try to fix it.


y-y-you too...
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 03:45 PM
I must be doing something horribly wrong, because none of these seem to work.


y-y-you too...
Report Abuse
DevDays is not online. DevDays
Joined: 16 Dec 2015
Total Posts: 112
28 Feb 2016 03:50 PM
Lisent, that's the complete script:

--Settings:
local yourpart = Instance.new("Part", game.Workspace)
local floatheight = 3
local position = Vector3.new(0,0,0)
--EndOfSettings
yourpart.Position = position
yourpart.CanCollide = false
yourpart.Anchored = false

local BAV = Instance.new("BodyAngularVelocity", yourpart)
BAV.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
BAV.AngularVelocity = Vector3.new(math.random(-50,100)/50,math.random(-100,100)/50,math.random(-100,100)/50)

local bP = Instance.new("BodyPosition", yourpart)
bP.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bP.Position = Vector3.new(yourpart.Position)

local float = coroutine.wrap(function()
while wait() do
for i = -1,1,2 do
for ii = 1,floatheight, 0.1 do
bP.Position = bP.Position+Vector3.new(0,(ii/floatheight)*i,0)
wait()
end
end
end
end)
float()

Run this without editing anything on an empty baseplate, if this is what you would like to see reply back.


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Feb 2016 03:50 PM
did you forget to parent p to the part. i put the script in the part itself instead of workspace but you can take it out and do local p = workspace.Part or whatever
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 04:02 PM
@Dev did it, still doesn't work.

@master I did, it didn't work.

I'm now just messing around with Body and angular velocity.


y-y-you too...
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
28 Feb 2016 04:03 PM
what's happening? it works perfectly for me
Report Abuse
ElectroTM is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
28 Feb 2016 04:16 PM
Litterally nothing but this is working (and even this is a little unpredictable):

I have a BodyAngularVelocity in my part set to 0,2,0

I have a BodyVelocity in the part with a script (also in the part):

BV=script.Parent:WaitForChild("BodyVelocity")
up=true

if up then
wait(1)
up=false
else
wait(1)
up=true
end

while wait() do
if up then
BV.Velocity=Vector3.new(0,1,0)
else
BV.Velocity=Vector3.new(0,-1,0)
end
end

Script doesn't work. I think that lua hates me. ;-;


y-y-you too...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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