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: Newbie Scripter

Previous Thread :: Next Thread 
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 06:53 PM
I have messed with tihs for a while know and cannot find out why this is not working.

This is supposed to make a object begin to fade a little every second until it it cannot be seen, then once it becomes completely transparent, CanCollide will be set false.

I do not want someone to write me another code, just a point in the right direction or perhaps a clue as to what I am doing wrong please.

Code Below:

script.Parent.Touched:connect(function(part)

Rock = game.Workspace.VanishingRocks.RockOne
Player = part.Parent:findFirstChild("Humanoid")

for x = 0, 1, 0.2 do
if Player ~= nil then

Rock.Transparency = x
wait(1)
if x == 1 then

Rock.CanCollide = false
wait(3)
Rock.CanCollide = true
Rock.Transparency = 0
end

end

end

end)
Report Abuse
1waffle1 is online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
02 Jan 2012 06:54 PM
Rock = ...
Player = part...
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
02 Jan 2012 06:55 PM
Try this:

script.Parent.Touched:connect(function(part)
Rock = game.Workspace.VanishingRocks.RockOne
Player = part.Parent:findFirstChild("Humanoid")
for x = 0, 1, 0.2 do
Rock.Transparency = x
wait(1)
end
Rock.CanCollide = false
wait(3)
Rock.CanCollide = true
Rock.Transparency = 0
end
end)

-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]-
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 06:56 PM
I didnt want a rewrite but I appreciate it. Thank you or your time, if I run into another problem I shall return.
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:00 PM
Hmm, I am looking at what you said I may have done wrong Waffle, and I am a bit unsure what is incorrect. I can see Player beingwrong but I am unsure why, and Rock I have no clue.
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
02 Jan 2012 07:11 PM
yayayyayaya a fellow forum enhancer user u b cool so i help u

    local Rock = game.Workspace.VanishingRocks.RockOne
    
    script.Parent.Touched:connect(function(part)
        local Player = part.Parent:FindFirstChild("Humanoid")
        if Player then
            for x = 0, 1, 0.2 do
                Rock.Transparency = x
                wait(1)
            end
            Rock.CanCollide = false
            wait(3)
            Rock.CanCollide = true
            Rock.Transparency = 0
        end
    end)

There you go, not overly rewritten, as you wanted.

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:25 PM
Thanks alot for all the help guys, although I believe I found out what the problem was. It didnt have anything to do with the code (At least I hope so) Thanks alot for your time and effort.

Only prooblem is that after you fall through the object, it goes through the script a second time because it was considered still touching I guess. Minor problem that I shall attempt to fix myself.
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:28 PM
Last question. How do I make it so the code does not activate again while it is already going? (It cycles through the transparencies again after you fall through while CanCollide is still set to false. Perhaps put the IF statement inside of the for loop?
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
02 Jan 2012 07:29 PM
    local deBounce = false
    local Rock = game.Workspace.VanishingRocks.RockOne
    
    script.Parent.Touched:connect(function(part)
        if deBounce then return end
        deBounce = true
        local Player = part.Parent:FindFirstChild("Humanoid")
        if Player then
            for x = 0, 1, 0.2 do
                Rock.Transparency = x
                wait(1)
            end
            Rock.CanCollide = false
            wait(3)
            Rock.CanCollide = true
            Rock.Transparency = 0
        end
        deBounce = false
    end)

Use debounce to stop your script from running more than once.

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:33 PM
I see,Thanks alot for the help. I don't really enjoy taking code from others because Im still learning myself, although I greatly appreciate it.
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
02 Jan 2012 07:37 PM
Do you need debounce explained? It wouldn't be too much trouble to help you understand.

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:40 PM
I think I understand it, Although a brief explaination would be nice. You are creating It to automatically say true at the start. When it goes into the functionit checks if it is false, if so then the function does not compute. If it is true or set as "Nil" then it goes through the function.

Im not great at explaining, although It would help greatly if you explain as well.
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 07:41 PM
False at the start*
Report Abuse
Chronok is not online. Chronok
Joined: 29 Dec 2011
Total Posts: 402
02 Jan 2012 08:08 PM
As you can see, I set a variable to false at the beginning of the script, yes?

And then after my anonymous function, I have this:

    if deBounce then return end
    deBounce = true

Ignore the first line for now. You see how I then set the variable, deBounce, to true? Now look back at the first line. If deBounce then return end. This is basically saying, if deBounce == true then return end. Which, simplified even more, is saying if deBounce is true then end the script.

You see, return will end a script where it is no matter what. So when it checks to see if deBounce is true (and if it is), then that means that the brick must have already been touched. And if that's the case, then 'return end', which stops the script from running a second time.

And then, finally, at the end of the script, deBounce = false. This makes it so that the script will execute its full source once more.

Sorry if I'm not very good at explaining. :/

{ ["Chronok"] = "Intermediate scripter/programmer." }
Report Abuse
Necrorave is not online. Necrorave
Joined: 07 Dec 2008
Total Posts: 108
02 Jan 2012 08:16 PM
That was perfect actiually. Thanks alot, for I didnt not know entirely what the Return statement did. I greatly appreciate your help.

PS: I am not great at explaining/Spelling either. As you may have already noticed.
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