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 » Game Design
Home Search
 

Re: Scripting help (from a nub)

Previous Thread :: Next Thread 
DerpForReal is not online. DerpForReal
Joined: 11 Nov 2015
Total Posts: 199
03 Oct 2016 07:33 PM
This is not that I need help with an entire game, just a few little things for a tycoon.
1. For the life of me, I can't figure out how to make a script for a dropper.
2. The button mechanics, getting objects to fade in and everything.
3. Maybe just some guidelines to help me along with this project, its my first project, I hope to keep it get a few visits over a decent time.
Thanks!
Report Abuse
KCNx12 is not online. KCNx12
Joined: 09 Jul 2008
Total Posts: 3230
03 Oct 2016 07:45 PM
The mechanics behind tycoons are quite simple in concept, but is understandable if it looks difficult if you are starting to code for the first time.

1. To make a script for a dropper, simply code for a specially named brick to spawn at the script's parent location.
Your first step is to place a brick into your map and set it's CanCollide variable to false, and the Anchored variable to true.
Second step is to place a script inside that brick you just placed and then create a script function to spawn bricks at a given interval.

Do you know the basics to scripting?
Report Abuse
DerpForReal is not online. DerpForReal
Joined: 11 Nov 2015
Total Posts: 199
03 Oct 2016 07:49 PM
Nope, this is my first time where I'm really dedicating myself to a game.
Report Abuse
KCNx12 is not online. KCNx12
Joined: 09 Jul 2008
Total Posts: 3230
03 Oct 2016 08:07 PM
I see, it's good that you are putting some motivation into making games!
Half of game development is being willing to do it.

If you are starting for the first time, learning Lua (the scripting language) is a bit of an uphill climb.
I would honestly not recommend jumping into learning how to code by learning how everything works from the ground up, you will get confused and frustrated.

I would recommend grabbing a tycoon starter kit from free models and learn how to script from there. More times than not, there are bits of code written in green (editing notes, they do not affect the script in any form) that will instruct you on what to do.

Here's an example. I coded a simple dropper script for you.
Just copy and paste this code into a script located inside of a brick, then elevate the brick a little bit off the ground and press Play in your toolbar on the top of your screen.
The Play button should look like a blue play button with a grey ROBLOX figure in front of it.

function dropBrick() --This is a function that I created for this script
local p = Instance.new("Part") --This line here is where the script summons a new brick that I will define as "p"
p.Position = script.Parent.Position --This line summons the brick "p" at the location where you placed the brick containing this script!
p.Size = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2)) --This is a little more complex than you need to know!
-- The above line alters the size of the brick I want the script to spawn, but I am letting the script decide what size to make the brick.
p.BrickColor = BrickColor.new("Medium stone grey") --The brick "p" will be summoned with the colour indicated in quotations.
-- If you want to change the colour so it is not grey, simply change the name in quotations to the name of a colour inside a brick's properties tab.
p.Material = "Corroded Metal" --Same as above, I am setting the material of the summoned brick to what I want.
p.BottomSurface = 0 --Summoned bricks will have studs on the top and bottom, these two lines changes that so the entire brick is smooth!
p.TopSurface = 0
p.Name = "TycoonBrick" --This is the OFFICIAL name of the brick that will be dropped. So if you want to see it in Workspace, look for this name!
p.Parent = script.Parent --In order to reduce spam inside Workspace, I have placed the brick's location within Workspace to inside the parent brick alongside the script.
end --This ends the function I defined above, which was dropBrick()


while true do --Basically saying, while this script is running, do what I am about to say next...
wait(2) --Wait for however many seconds... and then...
dropBrick() --Drop the brick I created above!
end

Let me know if you have any further questions, I am not sure if I want to answer #2 and #3 until you understand a little bit of scripting :P
Report Abuse
DerpForReal is not online. DerpForReal
Joined: 11 Nov 2015
Total Posts: 199
03 Oct 2016 08:13 PM
I understand basically how lua and studio work, I just can't do them myself. I understand what you are saying. Thanks. I'll test it.
Report Abuse
DerpForReal is not online. DerpForReal
Joined: 11 Nov 2015
Total Posts: 199
03 Oct 2016 08:18 PM
I've tried it, moved the brick a little off the ground, and played. I used a local script. Is that what I need to do? If so, it didn't work.
Report Abuse
StringedVortex is not online. StringedVortex
Joined: 28 Jun 2015
Total Posts: 1846
03 Oct 2016 08:24 PM
Values


there are three types of Values

Boolean Value = true or false

IntValue = Number FE: 1 2 3 or 4

String Value = words. But in Lua Terms You always have to Put "These quotations around the words"

this should help you on your journey of making a tycoon
Report Abuse
KCNx12 is not online. KCNx12
Joined: 09 Jul 2008
Total Posts: 3230
03 Oct 2016 08:28 PM
Do not use a local script.
Local scripts are for functions that you want to communicate to the player only instead of the server.
We are trying to spawn the brick on the game server, so you would use a regular script.
Report Abuse
DerpForReal is not online. DerpForReal
Joined: 11 Nov 2015
Total Posts: 199
03 Oct 2016 08:33 PM
I got it to work, thanks for that script, everything I had tried didn't work. What about numbers 2 and 3? Any advice on that?
Report Abuse
KCNx12 is not online. KCNx12
Joined: 09 Jul 2008
Total Posts: 3230
03 Oct 2016 08:52 PM
On number two, having objects fade in is probably a scope too big to take right now if you are just starting off.
It would involve having the script select every single brick within a model and fade their transparency from 1 to 0 in a set amount of time.
I have pasted a script down below that will fade in your model should you really want a fading model, but I don't think it will make sense until you learn a little bit more.

To use the script, just place it inside your model. That's it, all done!

On number three, the only guidelines I can offer is to simply do not work beyond what you are capable of. I am not saying to limit your creativity, but know when you are shooting for more than just the stars.
But if that goal is not out of reach, ask for help!
Hopefully someone who is a better scripter than me will help you out.

Here's the script: It goes in a regular script.
--I don't have time to annotate everything here, sorry!
Parts = {}
OnlySet = {}
function fadeParts()
for i = 1, #Parts do
local a = Parts[Parts[i]]
if Parts[i].Transparency > a then
Parts[i].Transparency = Parts[i].Transparency -0.01
end
end
end

function setParts()
for i = 1, #OnlySet do
OnlySet[i].Transparency = 0
end
end

function findParts(parent)
for _,v in pairs(parent:GetChildren()) do
if v.className == "Part" then
table.insert(Parts,v)
Parts[v] = v.Transparency
if v.Transparency < 0.1 then
table.insert(OnlySet,v)
end
v.Transparency = 1
elseif v.className == "Model" then
findParts(v)
end
end
end

findParts(script.Parent)
for i = 1, 101 do
fadeParts()
wait()
end
setParts()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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