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: Trying to make a door

Previous Thread :: Next Thread 
electrobolt22 is not online. electrobolt22
Joined: 23 Jul 2011
Total Posts: 248
14 Dec 2012 07:56 AM
Ok I'm a REALLY bad scripter so I decided to take a poke around in the wiki to try and find out how to put together a script and so I "thought" I had enough to make my own script but its clearly broken.

Here it is:

function onTouched
game.Workspace.Door.Transparency= 0.1
game.Workspace.Door.Transparency= 0.2
game.Workspace.Door.Transparency= 0.3
game.Workspace.Door.Transparency= 0.4
game.Workspace.Door.Transparency= 0.5
game.Workspace.Door.CanCollide= False
wait(3)
gamr.Workspace.Door.Transparency= 0.4
game.Workspace.Door.Transparency= 0.3
game.Workspace.Door.Transparency= 0.2
game.Workspace.Door.Transparency= 0.1
game.Workspace.Door.Transparency= 0
game.Workspace.Door.CanCollide= True

end


Now I understand this could be horribly wrong and if so how do I fix it?
Report Abuse
Voidion is not online. Voidion
Joined: 01 Aug 2011
Total Posts: 2668
14 Dec 2012 07:59 AM
function onTouched()
game.Workspace.Door.Transparency = 0.1
game.Workspace.Door.Transparency = 0.2
game.Workspace.Door.Transparency = 0.3
game.Workspace.Door.Transparency = 0.4
game.Workspace.Door.Transparency = 0.5
game.Workspace.Door.CanCollide = False
wait(3)
gamr.Workspace.Door.Transparency = 0.4
game.Workspace.Door.Transparency = 0.3
game.Workspace.Door.Transparency = 0.2
game.Workspace.Door.Transparency = 0.1
game.Workspace.Door.Transparency = 0
game.Workspace.Door.CanCollide = True
end
script.parent.Touched:connect(onTouched)
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:00 AM
You need to define a brick to get touched for this script to run.

brick = script.Parent

brick.Touched:connect(function()
game.Workspace.Door.Transparency= 0.1
wait()
game.Workspace.Door.Transparency= 0.2
wait()
game.Workspace.Door.Transparency= 0.3
wait()
game.Workspace.Door.Transparency= 0.4
wait()
game.Workspace.Door.Transparency= 0.5
game.Workspace.Door.CanCollide= False
wait(3)
gamr.Workspace.Door.Transparency= 0.4
wait()
game.Workspace.Door.Transparency= 0.3
wait()
game.Workspace.Door.Transparency= 0.2
wait()
game.Workspace.Door.Transparency= 0.1
wait()
game.Workspace.Door.Transparency= 0
game.Workspace.Door.CanCollide= True
end
Report Abuse
Voidion is not online. Voidion
Joined: 01 Aug 2011
Total Posts: 2668
14 Dec 2012 08:03 AM
Or you could use a loop and have:
for i=1, 5 do
game.Workspace.Door.Transparency = 0.1
end

Link: http://wiki.roblox.com/index.php/Loops
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:04 AM
That does not help. That makes it go to 0.1 five times...
I think you meant

for i=1, 5 do
game.Workspace.Door.Transparency = game.Workspace.Door.Transparency + 0.1
end


and


for i=1, 5 do
game.Workspace.Door.Transparency = game.Workspace.Door.Transparency - 0.1
end
Report Abuse
electrobolt22 is not online. electrobolt22
Joined: 23 Jul 2011
Total Posts: 248
14 Dec 2012 08:04 AM
Ok forgive me if I haven't understood but I'm testing it right now and I put the script into the door and it didn't work so I tried putting it into workspace and that didn't work may you tell me what I've done wrong?
Report Abuse
Voidion is not online. Voidion
Joined: 01 Aug 2011
Total Posts: 2668
14 Dec 2012 08:05 AM
For got the wait()
for i=1, 5 do
wait(0.1) --Could be anything
game.Workspace.Door.Transparency = 0.1
end
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:05 AM
Send us the model? We can help for you.
Report Abuse
Voidion is not online. Voidion
Joined: 01 Aug 2011
Total Posts: 2668
14 Dec 2012 08:06 AM
@jelly134

Whoops. Yeah, sorry.
either of them worked. :S
Report Abuse
electrobolt22 is not online. electrobolt22
Joined: 23 Jul 2011
Total Posts: 248
14 Dec 2012 08:07 AM
Aye here's the model

http://www.roblox.com/Broke-Door-item?id=100489293
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:10 AM
script.Parent.Touched:connect(function()
for i=1, 5 do
script.Parent.Transparency = script.Parent.Transparency + 0.1
wait()
end
game.Workspace.Door.CanCollide = false
wait(3)
for i=1, 5 do
script.Parent.Transparency = script.Parent.Transparency + 0.1
wait()
end
game.Workspace.Door.CanCollide = true
end)



--There were a few spelling mistakes, like gamr instead of game and False instead of false and True instead of true. Fixed now.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:11 AM
--sorry error in that last one, Truly fixed:


script.Parent.Touched:connect(function()
for i=1, 5 do
script.Parent.Transparency = script.Parent.Transparency + 0.1
wait()
end
game.Workspace.Door.CanCollide = false
wait(3)
for i=1, 5 do
script.Parent.Transparency = script.Parent.Transparency - 0.1
wait()
end
game.Workspace.Door.CanCollide = true
end)
Report Abuse
electrobolt22 is not online. electrobolt22
Joined: 23 Jul 2011
Total Posts: 248
14 Dec 2012 08:15 AM
Ok thanks! I put the script in and its working and just wondering could I tweak the + 0.1 to make it have two decimal places such as 0.01 or 0.05?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:19 AM
Yes as long as you change it to the following:

targetTransparency = 0.5 --The transparency you want to to change to
increment = 0.1 --The amount you want it to change by

num = targetTransparency/increment

script.Parent.Touched:connect(function()
for i=1, num do
script.Parent.Transparency = script.Parent.Transparency + increment
wait()
end
game.Workspace.Door.CanCollide = false
wait(3)
for i=1, num do
script.Parent.Transparency = script.Parent.Transparency - increment
wait()
end
game.Workspace.Door.CanCollide = true
end)
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:20 AM
So you would make increment 0.05 or 0.01
Report Abuse
electrobolt22 is not online. electrobolt22
Joined: 23 Jul 2011
Total Posts: 248
14 Dec 2012 08:22 AM
Ok thanks! Its all working now.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 08:28 AM
You're welcome!
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
14 Dec 2012 09:46 AM
script.Parent.Touched:connect(function()
for i = 0,1,.01 do
script.Parent.Transparency = i
wait()
end
script.Parent.CanCollide = false
wait(1)
for i = 1,0,-0.01 do
script.Parent.Transparency = i
wait()
end
script.Parent.CanCollide = true
end)
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 09:50 AM
He only wants transparency at 0.5 after the loop, but other than that, good one. I always forget about that awesome quality of for loops.
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