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: How can I make this script for many parts?

Previous Thread :: Next Thread 
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:08 PM
I have many parts names "Plate"

and each have this script in it:
-----------------------------------------------------------
script.Parent.Touched:connect(function(part)
script.Parent.Transparency = .25
wait(.5)
script.Parent.Transparency = .5
wait(.5)
script.Parent.Transparency = .75
wait(.5)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
end)
-----------------------------------------------------------

Well I need that in one script, not in each part. Can I have a script with this?
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
31 Mar 2013 03:11 PM
Or you put the script in every part:

local OS = TheScriptYouWantInAll
for k,v in pairs(workspace:GetChildren()) do
if v:IsA("Part") then OS:clone().Parent = v end
end

Or you could 1 script for all:
(I added also once a part is touched and it's touched agian, nothing happens)

for k,part in pairs(workspace:GetChildren()) do
if part:IsA("Part") then
local con = false
con=part.Touched:connect(function(p)
con:disconnect()
part.Transparency = .25
wait(.5)
part.Transparency = .5
wait(.5)
part.Transparency = .75
wait(.5)
part.Transparency = 1
part.CanCollide = false
end)
end
end
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 03:12 PM
You can try something like this in the Plates' Parent:

    for Index, Key in pairs(script.Parent:GetChildren()) do
      if Key:IsA("BasePart") and Key.Name == "Plate" then
        Key.Touched:connect(function(part)
          --Your code
        end )
      end
    end

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:16 PM
@knight

"16:14:51.931 - Touched is not a valid member of Model"


:/
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:23 PM
bump...
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 03:23 PM
Models shouldn't be BaseParts. . . Not sure why you're getting that output. Are you putting the script with all of the plates?

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:24 PM
There is a Model named "Poof Plates"
inside is

the script
and also all the parts each called "Plates"
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 03:25 PM
Post the script you used.

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:26 PM
This is my original script:
-------------------------------------------------------------------------
script.Parent.Touched:connect(function(part)
script.Parent.Transparency = .25
wait(.5)
script.Parent.Transparency = .5
wait(.5)
script.Parent.Transparency = .75
wait(.5)
script.Parent.Transparency = 1
script.Parent.CanCollide = false

end)
-------------------------------------------------------------------------
Could you put this correctly into your script?
All the info you may need is in the post above
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:29 PM
?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 03:36 PM
Ah, I see. Put your code where I indicated, but instead of "script.Parent", use "Key".

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 03:53 PM
16:51:31.750 - Workspace.Collapsing Plates.Poof Plates.Script:18: unexpected symbol near ')'


I changed Key to Poof, hope that is OK

and here is the 20 line Script


--Poof goes the plates! -chubbs21

for Index, Poof in pairs(script.Parent:GetChildren()) do
if Poof:IsA("BasePart") and Poof.Name == "Plate" then
Poof.Touched:connect(function(part)
Poof.Transparency = .25
wait(.5)
Poof.Transparency = .5
wait(.5)
Poof.Transparency = .75
wait(.5)
Poof.Transparency = 1
Poof.CanCollide = false

end)


end)
end
end
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 04:10 PM
bump
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 04:12 PM
    for Index, Poof in pairs(script.Parent:GetChildren()) do
      if Poof:IsA("BasePart") and Poof.Name == "Plate" then
        Poof.Touched:connect(function(part)
           Poof.Transparency = .25
           wait(.5)
            Poof.Transparency = .5
           wait(.5)
            Poof.Transparency = .75
           wait(.5)
            Poof.Transparency = 1
           Poof.CanCollide = false
        end)
      end
    end

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 04:18 PM
It worked!

Also do you play TheGamer101's Sword Fight Tournament? ;)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
31 Mar 2013 04:22 PM
No problem. And not for a long time.

(╯°□°)> KMXD
Report Abuse
chubbs21 is not online. chubbs21
Joined: 31 Dec 2008
Total Posts: 18991
31 Mar 2013 04:27 PM
Well, I happen to make maps for gamer. (Already have 2 of mine in the game)

and well,

http://www.roblox.com/Collapsing-Plates-For-TheGamer101-item?id=111378079
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