|
| 02 Feb 2014 03:35 PM |
I'm fairly new to Lua but I can understand little bits of pieces and change pre-written scripts but I can't write my own.
I'm trying to be able to get a window with 7 parts to move up in sequence when a player clicks on it. Anyone? |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 03:37 PM |
parts = {} for i = 1,7 do local p = Instance.new("Part",workspace) p.Parent = game.Workspace table.insert(parts,p) cd = Instance.new("ClickDetector",p) cd.Clicked:connect(function() for i,v in pairs(parts) do v.CFrame = v.CFrame * CFrame.new(0,10,0) end end) end
|
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 03:38 PM |
parts = {} for i = 1,7 do local p = Instance.new("Part",workspace) p.Parent = game.Workspace p.Anchored = true p.CFrame = p.CFrame * CFrame.new(i*5,0,0) table.insert(parts,p) cd = Instance.new("ClickDetector",p) cd.Clicked:connect(function() for i,v in pairs(parts) do v.CFrame = v.CFrame * CFrame.new(0,10,0) end end) end
|
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 03:42 PM |
--forget what i said up there, This one works, i just tested it in solo parts = {} for i = 1,7 do local p = Instance.new("Part",workspace) p.Parent = game.Workspace p.Anchored = true p.CFrame = p.CFrame * CFrame.new(i*5,5,0) table.insert(parts,p) cd = Instance.new("ClickDetector",p) cd.MouseClick:connect(function() for i,v in pairs(parts) do v.CFrame = v.CFrame * CFrame.new(0,10,0) end end) end |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 03:45 PM |
@Jones, thank you very much but it seems I'm doing something wrong. I have a click detector and the script placed inside the model. I'm pretty sure they have to go into a specific block but I'm not sure which one. All of the parts I named and put them into the script, but I'm not sure if that's right. Here's what I have:
parts = {P1, P2, P3, P4, P5, Glass, P6} for i = 1,7 do local p = Instance.new("Part",workspace) p.Parent = game.Workspace p.Anchored = true p.CFrame = p.CFrame * CFrame.new(i*5,0,0) table.insert(parts,p) cd = Instance.new("ClickDetector",p) cd.Clicked:connect(function() for i,v in pairs(parts) do v.CFrame = v.CFrame * CFrame.new(0,10,0) end end) end |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 03:47 PM |
I just used your most recent script that you tested and it doesn't work either. I'm doing something wrong for sure. |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 03:48 PM |
model = script.Parent getparts = model:GetChildren()
for i=1,#getparts do cd = Instance.new("ClickDetector",getparts[i]) cd.Clicked:connect(function() for i=1,7 do for i=1,#getparts do getparts[i].CFrame = getparts[i].CFrame + Vector3.new(0,1,0) end end end) end |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 03:49 PM |
that was just a example, but put a click detector in your selected bricks and insert them into the table like i did, leave the table blank at first though.
then use the for i,v in pairs to move them up |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 03:51 PM |
| :( not making sense to me. Can I get your skype or something? |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 03:55 PM |
--put this script inside your model with your selected bricks, and just leave the script alone parts = {} mc = script.Parent:GetChildren() for i,v in pairs(mc) do if v.ClassName == "Part" then table.insert(parts,v) cd = Instance.new("ClickDetector",v) cd.MouseClick:connect(function() for i,v in pairs(parts) do v.CFrame = v.CFrame * CFrame.new(0,3,0) end end) end end |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 03:57 PM |
Yay it works! Problem being though, is that I would like it to "slide" in a sense and on second click go down. |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 04:03 PM |
--put this script inside your model with your selected bricks, and just leave the script alone parts = {} direction = "slide" mc = script.Parent:GetChildren() for i,v in pairs(mc) do if v.ClassName == "Part" then table.insert(parts,v) cd = Instance.new("ClickDetector",v) cd.MouseClick:connect(function() for i,v in pairs(parts) do if direction == "slide" then v.CFrame = v.CFrame * CFrame.new(3,0,0) direction = "down" elseif direction == "down" then v.CFrame = v.CFrame * CFrame.new(0,-3,0) direction = "slide" end end end) end end --this one would make the bricks slide on the x axis then on second click, make them go down, and then it resets |
|
|
| Report Abuse |
|
|
|
| 02 Feb 2014 04:15 PM |
Great! Thank you very much. If it's not too much to ask for, can you set it so they actually slide and don't just instantly change position? I've edited the script so that it fits perfectly:
parts = {} direction = "slide" mc = script.Parent:GetChildren() for i,v in pairs(mc) do if v.ClassName == "Part" then table.insert(parts,v) cd = Instance.new("ClickDetector",v) cd.MouseClick:connect(function() for i,v in pairs(parts) do if direction == "slide" then v.CFrame = v.CFrame * CFrame.new(0,1.3,0) direction = "down" elseif direction == "down" then v.CFrame = v.CFrame * CFrame.new(0,-1.3,0) direction = "slide" end end end) end end
|
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Feb 2014 04:47 PM |
| Also with that script, each time it's activated it creates a new ClickDetector in each part. |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 04:55 PM |
| i can't make them slide smoothly without some brick lag |
|
|
| Report Abuse |
|
|
999kko
|
  |
| Joined: 05 May 2012 |
| Total Posts: 235 |
|
| |
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 04:58 PM |
| you'd still be able to see that they're moving 1 by 1 |
|
|
| Report Abuse |
|
|