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: Click Detector help

Previous Thread :: Next Thread 
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
06 Nov 2014 08:33 AM
Hey, while developing something, I was stuck, tbh I'm really not that great of a scripter.
So I was trying to make a script that executes a function which makes a model (Which like 6 Bricks in it) disappear (Go transparency 1 and cancollide false) on click of the click detecor.
So this is the script I have so far:
function onClicked()
local m = script.Parent.Parent.traps:GetChildren()
for i = 1, #m do
wait(1.5)
m.Transparency = .5
wait(1)
m.Transparency = 1
m.CanCollide = false
wait(6)
m.CanCollide = true
m.Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

IF you could help me I would be grateful :) As mentioned I am really not a very good scripter so there are probably lots of errors
Report Abuse
EliteDerper is not online. EliteDerper
Joined: 05 Feb 2012
Total Posts: 2288
06 Nov 2014 08:35 AM
function onClicked()
local m = script.Parent.Parent.traps:GetChildren()
for i = 1, #m do
wait(1.5)
m[i].Transparency = .5
wait(1)
m[i].Transparency = 1
m[i].CanCollide = false
wait(6)
m[i].CanCollide = true
m[i].Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
06 Nov 2014 08:42 AM
Thanks for the help, but one problem still is, it removes onebrick, puts it back, removes next brick, puts it back etc. Id like it to have it take remove one at a time till all are gone and then make the walkable/visible again.
Report Abuse
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
06 Nov 2014 12:26 PM
bump
Report Abuse
DcentroCaniniusCorax is not online. DcentroCaniniusCorax
Joined: 19 Feb 2011
Total Posts: 50
06 Nov 2014 12:37 PM
It dosent remove it, it makes it invincible.
At least it shouldn't remove it, as there's nothing in the script above that says to remove a part. If it IS removing a part, you have a higher chance of a different script doing so then the one above.
Report Abuse
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
06 Nov 2014 12:45 PM
^I meant making it invisible and and making it noncancollide causing you to be able to walk through the brick.
Report Abuse
Sinecure is not online. Sinecure
Joined: 25 Nov 2010
Total Posts: 871
06 Nov 2014 12:54 PM
function onClicked()
local m = script.Parent.Parent.traps:GetChildren()

for i = 1, #m do
wait(1.5)
m.Transparency = .5
wait(1)
m.Transparency = 1
m.CanCollide = false
wait(6)
m.CanCollide = true
m.Transparency = 0
end

end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Conceptually "for i = 1, #m do" is doing "for each part in the model"

so for a model with parts Part1, Part2, and Part3, it's doing...

wait for 1.5 seconds
set Part1's transp. to .5
wait for 1 second
set Part1's transp to 1
make Part1 nonsolid
wait 6 seconds
make Part1 solid
make Part1 visible

next,

wait for 1.5 seconds
set Part2's transp to .5
wait for 1 second
set Part1's transp to 1
etc...

This is why you're having a problem.
You'll need to do something more like this:

wait 1 second
for all parts in the model, set transparency to .5
wait 1.5 seconds
for all parts in the model, set transparency to 1 and make nonsolid
etc...
Report Abuse
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
06 Nov 2014 01:28 PM
How can I change all parts in the model at once(in transparency and cancollide)?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
06 Nov 2014 02:12 PM
function onClick()
local m = script.Parent.Parent.traps:GetChildren()
wait(1.5)
for I,v in pairs(m) do
v.Transparency = .5
end
wait(1)
for I,v in pairs(m) do
v.Transparency = 1
v.CanCollide = false
end
wait(6)
for I,v in pairs(m) do
v.CanCollide= true
v.Transparency = 0
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
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