of     1   

LomoTheHoarder
#159653098Wednesday, April 08, 2015 12:23 AM GMT

I have been making a tycoon and what I wanted to do was to make it so I had to change the most minimal things if I wanted to add things. (This is a script that "collects" ores) ores = game.Lighting:FindFirstChild("Ore") thiss = script.Parent.Parent.Parent.Parent name = script.Parent.Parent function onTouched(hit) this = ores:FindFirstChild(hit.Name) if this then if this.Name == hit.Name then ore = thiss:FindFirstChild(hit.Name) ore.Value = ore.Value + 1 name.Name = hit.Name..": "..ore.Value hit:remove() end else print("No Touchy") end end script.Parent.Touched:connect(onTouched) What it does is find the name of the ore, then find the ore IntValue within the tycoon itself and adds +1 to it. I'm pretty sure I coded it to be as little as it could be to do everything I want/need it to do for now.
AbstractMadness
#159653432Wednesday, April 08, 2015 12:27 AM GMT

NOOO NO NO NO WTF GIVE ME YOUR ASTRA YOU DUMB ASS local ores = game.Lighting:FindFirstChild("Ore") local name = script.Parent.Parent local thiss = name.Parent.Parent script.Parent.Touched:connect(function(hit) local this = ores:FindFirstChild(hit.Name) if this then local ore = thiss:FindFirstChild(hit.Name) ore.Value = ore.Value + 1 name.Name = hit.Name..": "..ore.Value hit:Destroy() end end)
amanda
#159653668Wednesday, April 08, 2015 12:30 AM GMT

This is confusing. The variable names are not very clear of what they represent, you shouldn't store things in Lighting, but in ServerStorage. I am fairly sure you have one or two checks that are completely unnecessary, however I cannot re-write your code to be the best it can be because I don't know exactly what your variables are.
LomoTheHoarder
#159653806Wednesday, April 08, 2015 12:33 AM GMT

May I ask why ServerStorage is preferred over Lighting? Is there any benefits over one or the other? I personally prefer lighting because it was the way to do it for a long time and I never had any problems with it yet.
LomoTheHoarder
#159653914Wednesday, April 08, 2015 12:35 AM GMT

Also.. Here.. ores = game.Lighting:FindFirstChild("Ore") thiss = script.Parent.Parent.Parent.Parent name = script.Parent.Parent function onTouched(hit) this = ores:FindFirstChild(hit.Name) if this then -- This detects if it was a ore. if this.Name == hit.Name then -- This detects if it's the correct ore ore = thiss:FindFirstChild(hit.Name) ore.Value = ore.Value + 1 name.Name = hit.Name..": "..ore.Value hit:remove() end else -- This is incase it isn't an ore. print("No Touchy") end end script.Parent.Touched:connect(onTouched)
AbstractMadness
#159654023Wednesday, April 08, 2015 12:37 AM GMT

use. server. storage.
LomoTheHoarder
#159654120Wednesday, April 08, 2015 12:38 AM GMT

Abstract, if you are going to say something. Please explain why. Otherwise it's a useless spam comment.
amanda
#159654205Wednesday, April 08, 2015 12:39 AM GMT

@lomo, because ServerStorage was specifically created for that purpose, to hold models and other server-stuff. Read the second paragraph down on this link: http://wiki.roblox.com/index.php?title=API:Class/Lighting Also, you will get better help here if you are up to date in best practices.
AbstractMadness
#159654505Wednesday, April 08, 2015 12:43 AM GMT

The Lighting service controls all of the environmental variables in a map, including the colors of light, time of day, angle of celestial bodies, etc. The Lighting service was commonly used for storage since scripts did not run and models weren't rendered. However, ServerStorage and ReplicatedStorage should now be used for this purpose instead.
LomoTheHoarder
#159654793Wednesday, April 08, 2015 12:48 AM GMT

Okay, I read a bit on that. I never really had a problem with lighting considering I never noticed anything wrong with it. So generally speaking I should be using ServerStorage and not ReplicatedStorage unless I want to do stuff that isn't directly only related to the client/server?

    of     1