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: Why is this not working...?

Previous Thread :: Next Thread 
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
05 Dec 2014 10:25 PM
Hello, I've been having trouble with a script that moves a Model in workspace called, "Sign" It's supposed to, move it right 10 studs smoothly, so like sliding not teleporting. Then move it back again 10 studs, then repeat. Sorry if its very bad, I haven't scripted in a while...

i = game.Workspace.Sign:GetChildren()

while true do

for i = 1,10 do
wait(0.01)
i.CFrame = CFrame.new(1, 1, 1)
end

for i = 1,10 do
wait(0.01)
i.CFrame = CFrame.new(-1, -1, -1)
end
end

Output says: 23:20:52.936 - Workspace.Sign.Script:7: attempt to index local 'i' (a number value)

I'd gladly appreciate it if you could help!
Report Abuse
FrozenSmite is not online. FrozenSmite
Joined: 17 Jul 2013
Total Posts: 2242
05 Dec 2014 10:29 PM
You have i assigned to the counter value of for i=1,10 and also the children of sign.

parts = game.Workspace.Sign:GetChildren()
for i=1,#parts do
parts[i].CFrame = CFrame.new(parts[i].Position+Vector3.new(1,1,1))
end
for i=1,#parts do
parts[i].CFrame = CFrame.new(parts[i].Position-Vector3.new(1,1,1))
end

I dont know if this will work

♫♪ repeat wait() until 1+1 ~= 2 ♪♫
Report Abuse
cycoboy83 is not online. cycoboy83
Joined: 31 May 2011
Total Posts: 831
05 Dec 2014 10:34 PM
Your first problem is that GetChildren() returns a table containing the parts, so attempting to CFrame that is just going to cause another error. Secondly, when you use for i = 1,10, you actually copy over that table with the integer value that that loop is at.

So essentially, change your variable names. Either the i in your for loop or the i for the GetChildren(). Secondly, I'm pretty sure rather than using GetChildren, you could just set a primarypart by using

game.Workspace.Sign.PrimaryPart = game.Workspace.Sign.PartName

then just CFraming the entire model via

game.Workspace.Sign:SetPrimaryPartCFrame(CFrame.new(x,y,z))
Report Abuse
FrozenSmite is not online. FrozenSmite
Joined: 17 Jul 2013
Total Posts: 2242
05 Dec 2014 10:35 PM
:O That's so useful
Is that new?

♫♪ repeat wait() until 1+1 ~= 2 ♪♫
Report Abuse
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
05 Dec 2014 10:42 PM
Thanks, but may I ask, what does setting a primary part do? Please excuse my stupidness...
Report Abuse
cycoboy83 is not online. cycoboy83
Joined: 31 May 2011
Total Posts: 831
06 Dec 2014 12:34 AM
I'm no expert on CFrame but from my experiences, rotating or moving that part around via SetPrimaryPartCFrame will move everything inside that model too.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Dec 2014 12:35 AM
It's the part that actually takes on the given CFrame and everything else moves/rotates relative to that
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
06 Dec 2014 01:15 AM
CFrame is absolute position.
Vector3 adds to the current position.
Suppose you have a part on 1,2,2
You use Vector3.new(5,7,5)
so 1+5=6,2+7=9,2+5=7
That means the part will move to 6,7,7.
But CFrame, on the other hand, moves it to a absolute position.
Take the part that is on 6,7,7.
Use CFrame.new(0,0,0) on it.
It goes back to 0,0,0
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
06 Dec 2014 01:21 AM
Uh, no.
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