Advertisement
Kreno_Dev

Roblox Scripting Tutorial

Dec 20th, 2019
1,344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.27 KB | None | 0 0
  1. --[[
  2.     Created by: Krenodavid_Windows
  3.     v.1.0
  4.     About:
  5.     This is a script, published on Pastebin.com.
  6.     I Created this to help people learn LUA Coding in Roblox.
  7.     Maybe you already knew these, maybe not. I'm gonna explain you what I Know and how it works.
  8.    
  9. --]]
  10. -- First, let's get started with Variables.
  11. -- A Basic variable looks like this:
  12. local Example = 1 -- Syntax: local <Name> = <Value>
  13. -- Variables, can be created with other values too. For example here is a Boolean (Text Only) Value.
  14. local ExampleBoolean = "Example" -- Syntax: local <Name> = <"Text Value">
  15. -- You can have variables what are storing a Service, A New part (Instance.new()) etc.
  16. local RepFirst = game:GetService("ReplicatedFirst") -- This mostly helps you, in faster scripting.
  17. -- What it does is it lets you to short things. Example: RepFirst = game:GetService("ReplicatedFirst")
  18. -- You can have a variable that stores new parts too.
  19. local newPart = Instance.new("Part", workspace)
  20. -- Syntax: local <name> = Instance.new(<Type Of Part>, <It's Parent(Where to create it.)>
  21. -- And here are the Global Variables. (Every script can edit this value.)
  22. _G.ExampleGlobal = 1
  23. -- Syntax: _G.<Name> = <Value>
  24. -- Now let's Create a part and change it's color.
  25. local colorPart = Instance.new("Part", workspace) -- Creates the part.
  26. colorPart.Position = Vector3.new(0,20,0) -- Sets the part's Position (0=x,20=y,0=z)
  27. colorPart.BrickColor = BrickColor.Red() -- Changes brickcolor. (Set's the part's color to red.)
  28. colorPart.Anchored = true -- Anchors the part. (Makes the part to stay in it's position. It's not affected by gravity.)
  29. -- Now let's make the part, to change colors.
  30. while true do
  31.     colorPart.BrickColor = BrickColor.Red()
  32. wait (1)
  33.     colorPart.BrickColor = BrickColor.Green()
  34. wait (1)
  35.     colorPart.BrickColor = BrickColor.Blue()
  36. wait(1)
  37. end
  38.  
  39. -- You can change colors, by creating variables too.
  40. local RGBred = Color3.fromRGB(255, 0, 0) -- Red color in RGB.
  41. local RGBgreen = Color3.fromRGB(0, 255, 0) -- Green color in RGB.
  42. local RGBblue = Color3.fromRGB(0, 0, 255) -- Blue color in RGB.
  43. -- This means, variables can store color values too.
  44. -- Example: Part.Brickcolor = Color3.fromRGB(RGBred, RGBgreen, RGBblue)
  45. -- Thank you for watching this! Hope you learned something :)
  46. -- (End of: v1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement