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
 

[ Content Deleted ]

Previous Thread :: Next Thread 
pitaden is not online. pitaden
Joined: 21 Aug 2011
Total Posts: 2492
19 Dec 2013 08:58 PM
I'm working on a game called Eternal Frost, a game where everything has been frozen over from a nuclear war. I'm trying to make a script where the torch runs out after 10 minutes (600 seconds) but I don't know how to make a loop that goes on forever without repeating the script over and over. The code I've got so far is below.

torchFire is invisible and it also is where the fire is in along with the PointLight.
torchEnd is the visible end of the torch that has no use other than looks.
torch is the entire torch tool, the handle, torch end, and the invisible torch end.

Coding itself below.


torchFire = Workspace.Torch.PartFire
torchEnd = Workspace.Torch.Part
torch = Workspace.Torch

wait(2)
RandomNumberFuel = randomNumber(1, 0)

if(RandomNumberFuel == 1) then
wait(10)
end

if(RandomNumberFuel == 0) then
Instance.remove ("Fire", "PointLight", PartFire)
torchEnd.BrickColor = 'Mid Grey'
torch.ToolTip = ('A burnt out torch. Probably not going to be able to be lit again.')
torch.Name = ('Burnt Out Torch')

end

End of the script

If anyone can tell me how to make it loop without having to repeat it forever and/or give a way to remove an instance please tell me, since torches will be an essential part of the game.
Report Abuse
Madified is not online. Madified
Joined: 19 Apr 2011
Total Posts: 5292
19 Dec 2013 09:12 PM
[ Content Deleted ]
Report Abuse
Madified is not online. Madified
Joined: 19 Apr 2011
Total Posts: 5292
19 Dec 2013 09:14 PM
[ Content Deleted ]
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
19 Dec 2013 09:24 PM
A simpler way to do this:

Put an IntValue inside the script itself to designate the timer, so set the value to 600 to represent 10 minutes.

repeat wait(1)
script.Timer.Value = script.Timer.Value - 1
until script.Timer.Value <= 0
--function here

The timer will countdown until it reaches 0. the commented out line is where you will put YOUR function. I'm guessing some sortya function that will extinguish the fire or something.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
19 Dec 2013 09:27 PM
Or if you prefer to have a cooler function that would allow players to blow out their own torch to save fuel:

repeat wait(1)
script.Timer.Value = script.Timer.Value - 1
until script.Timer.Value <= 0 or script.TorchIsLit.Value == false
--function here

Same idea, but you also put a BoolValue into the script. Turning the torch on and off is as simple as turning the value false because it uses the same function to blow out the torch.
Report Abuse
pitaden is not online. pitaden
Joined: 21 Aug 2011
Total Posts: 2492
19 Dec 2013 09:29 PM
That's almost correct, the only problem is that I'm trying to use Instance.remove instead of whatever is correct for removing an instance. If I find out whats used to remove instances then I'll be done with the script. Thanks Madified, I'm a complete and utter noob at scripting with Roblox Lua, I'm used to Javascript (if(){ }, else{ }, var X = 1, etc.)
Report Abuse
pitaden is not online. pitaden
Joined: 21 Aug 2011
Total Posts: 2492
19 Dec 2013 09:30 PM
Also I don't have a fuel system or warmth system yet, I just started working on the game a few days ago, but I plan to add both of those.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
19 Dec 2013 09:44 PM
Ok fine let me just do it for you.

This script is made in rthe assumption that the Torch is just made up of a brown part with/without torch mesh with a black brick welded at the top.
It's also made in the assumption that the torch is a Tool
I'm also going to assume that the part holding the Fire and PointLight objects is named Coal.
Obviously if I'm wrong you can change it to suit you or completely ignore the help. :P


script.Parent.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()
if script.Timer.Value > 1 and script.TorchIsLit.Value == false then
script.TorchIsLit.Value = true
script.Parent.Fire.Enabled = true; script.Parent.PointLight.Enabled = true
script.Parent.Coal.BrickColor = BrickColor.new("Dark stone grey")
repeat wait(1)
script.Timer.Value = script.Timer.Value - 1
until script.Timer.Value <= 0 or script.TorchIsLit.Value == false
script.Parent.Fire.Enabled = false; script.Parent.PointLight.Enabled = false
script.Parent.Coal.BrickColor = BrickColor.new("Medium stone grey")
elseif script.Timer.Value > 1 and script.TorchIsLit.Value == true then
script.TorchIsLit.Value = false
script.Parent.Fire.Enabled = false; script.Parent.PointLight.Enabled = false
script.Parent.Coal.BrickColor = BrickColor.new("Black")
end end) end)

script.Parent.Unequipped:connect(function()
script.TorchIsLit.Value = false
script.Parent.Fire.Enabled = false; script.Parent.PointLight.Enabled = false
script.Parent.Coal.BrickColor = BrickColor.new("Black") end)

There I just made you an entire script.
Unequipping the torch will turn it off, saving fuel.
Report Abuse
pitaden is not online. pitaden
Joined: 21 Aug 2011
Total Posts: 2492
19 Dec 2013 10:12 PM
I'm not trying to find something for the torch not taking fuel when its not selected, what I'm trying to find is the coding thats used to remove instances, though I may use this script once I break it down into each step. I always do that with code that people tell me so I can understand it. I'm a newb with Roblox scripting, so I really need to find all the help that I'm able to get. I often perfer to do my own coding, but many times people just hand over the code instead of giving tips on what to do. I constantly see it in the scripting helpers section. I don't need anymore help with this script now, I'd rather find whatever function that removes instances is myself, I don't need it handed over to me on a golden platter.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
19 Dec 2013 10:49 PM
Part:Remove()
Part:Destroy()
game.Debris:Additem(Part, 1)

Take your pick. :/
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