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: What is wrong with this script?

Previous Thread :: Next Thread 
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:01 PM
Hmmm...can you help me fix this script? I think it has to do with the if functions...is there a different way of doing that?


function onTouched(hit)
if hit.Name == "Rocks" then
if hit.Transparency = 0 then
hit.Transparecy = 1
elseif hit.Transparency = 1 then
hit.Transparecy = 2
elseif hit.Transparency = 2 then
hit.Transparecy = 3
elseif hit.Transparency = 3 then
hit.Transparecy = 4
elseif hit.Transparency = 4 then
hit.Transparecy = 5
elseif hit.Transparency = 5 then
hit.Transparecy = 6
elseif hit.Transparency = 6 then
hit.Transparecy = 7
elseif hit.Transparency = 7 then
hit.Transparecy = 8
elseif hit.Transparency = 8 then
hit.Transparecy = 9
elseif hit.Transparency = 9 then
hit:remove()
end
end
end

script.Parent.Touched:connect(onTouched)



















Beginner scripter.
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:01 PM
Maybe with the use of an and?
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:07 PM
:0
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
25 Mar 2009 08:09 PM
function onTouched(hit)
if hit.Name == "Rocks" then
if hit.Transparency = 0 then
hit.Transparency = .1
elseif hit.Transparency = .1 then
hit.Transparency = .2
elseif hit.Transparency = .2 then
hit.Transparency = .3
elseif hit.Transparency = .3 then
hit.Transparency = .4
elseif hit.Transparency = .4 then
hit.Transparency = .5
elseif hit.Transparency = .5 then
hit.Transparency = .6
elseif hit.Transparency = .6 then
hit.Transparency = .7
elseif hit.Transparency = .7 then
hit.Transparency = .8
elseif hit.Transparency = .8 then
hit.Transparency = .9
elseif hit.Transparency = .9 then
hit:remove()
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:12 PM
Oh woops! Such a silly mistake!
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:21 PM
It still doesn't work though :/

Anyone else have any input here?

Report Abuse
Cull is not online. Cull
Joined: 16 Dec 2007
Total Posts: 1252
25 Mar 2009 08:32 PM
On an "if" line, you need a == instead of an =
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 08:36 PM
Does the same apply for elseifs?
Report Abuse
kisamebeast is not online. kisamebeast
Joined: 17 Jan 2008
Total Posts: 3086
25 Mar 2009 08:44 PM
You cud also do:

function Upgrade(val)
if val.Transparency = 9 then
val:remove()
else
val.Transparency = val.Transparency + 1
end
end

function onTouched(hit)
if hit.Name == "Rocks" then
Upgrade(hit)
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
Bannana97 is not online. Bannana97
Joined: 22 Jun 2008
Total Posts: 10215
25 Mar 2009 10:58 PM
[ Content Deleted ]
Report Abuse
Bannana97 is not online. Bannana97
Joined: 22 Jun 2008
Total Posts: 10215
25 Mar 2009 10:59 PM
[ Content Deleted ]
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 11:06 PM
Would that work with the 2 ifs like that? Ill have to experiment i a minute.
Report Abuse
Deadlybones is not online. Deadlybones
Joined: 11 Aug 2008
Total Posts: 2424
25 Mar 2009 11:12 PM
Alright sorry for all these posts guys but I got it working a bit. It goes to transparency 0.1 then stays there. Any ideas? Ill try to fix this too.
Report Abuse
Bannana97 is not online. Bannana97
Joined: 22 Jun 2008
Total Posts: 10215
26 Mar 2009 09:03 AM
[ Content Deleted ]
Report Abuse
Davidii is not online. Davidii
Joined: 17 Jul 2008
Total Posts: 1282
26 Mar 2009 09:30 AM
Here is a simple solution.

Going from 0 Transparency to 1 Transparency (then remove)

function onTouched(hit)
hit.Transparency = hit.Transparency + 0.1
if hit.Transparency < 0.1 then
hit:remove()
end
end

script.Parent.Touched:connect(onTouched)

Going from 1 Transparency to 0 Transparency (then remove)

function onTouched(hit)
hit.Transparency = hit.Transparency - 0.1
if hit.Transparency > 0.9 then
hit:remove()
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
kingddda is not online. kingddda
Joined: 11 Mar 2009
Total Posts: 63
26 Mar 2009 10:25 AM
I need help with where to put () and what to put in the exp: script.Parent.Anchored = true
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