Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- types of varibles on roblox
- varibles --a way to shorten scripts/store information -- example local.
- (so you dont have to write the same thing over and over you can use local)
- varibles give access to properties
- 1 "" (string)
- 2 1331 (number)
- 3 true/false (boolean)
- 4 game.Workspace. (object reference
- print = ("dogs are cool")
- Instance.new() -- allows you to insert things into your game from a script
- Ex:Instance.new("Brick")an object goes in the()
- how to do it Instance.new("brick",)
- Instance.new(brick,) tells to put the brick in the Workspace
- local myBrick = Instance.new("brick")
- myBrick.Trapsparency = 0.5
- myBrick.Anchored = true
- myBrick.Position = Vector3.new (5,5,5) -- this is how to position
- myBrick.Parent = game.Worspace -- always have this after the properties
- Functions generatePart (name) is = to PartNumberOne
- Instance.new(brick,) tells to put the brick in the Workspace
- local myBrick = Instance.new("brick")
- myBrick.Trapsparency = 0.5
- myBrick.Anchored = true
- myBrick.Position = Vector3.new (5,5,5)
- end -- any code needs to go between the function and the end
- generatePart()-- this let you save time instead of copying 50 lines
- generatePart()-- also makes your code neatter
- generatePart()-- functions make your save time and make your code neater
- generatePart()
- generatePart()
- Function Parameter/Argruments
- generatePart("PartNumberOne")goes to name
- generatePart() -- this is the Agrument and the function is the Parameter
- generatePart()
- generatePart()
- generatePart()
- -- you need to name the part add a name in the ()
- ex:generatePart(jijij) -- jijij is the name of the brick
- Arguements pass data to the function
- function printText(stringToPrint)
- print(stringToPrint
- end
- PrintText("hello dogs")
- PrintText("robux")
- built in functions
- 5 most popular
- 1 Destroy()
- 2 Clone()
- 3 ClearAllChildren()
- 4 wait()
- 5 print()
- when you do : its calling a function
- game.Workspace.MyBrick:Destroy() -- when you run the game this script destroies the part
- local myClone = game.Workspace.Brick:Clone()
- myClone.Parent = game.Workspace
- wait(5)
- game.Workspace.MyBrick:ClearAllChildren()
- -- this script will clone the part then it will wait 5 seconds then will ClearAllChildren
- print("HELLO")
- -- print is a why to see where your script broke.
- end
- Events -- are what help things happen/trigger things
- Ex:step on a banana then you trip -- triggered that
- Example of a touched event script
- script.Parent.Touched:Connect(function(hit)
- if game.Players:GetPlayersFromCharacter(hit.Parent) then
- hit.Parent.Humanoid.Sit = true
- end
- end)
- -- this script needs to go in the object like the banana
- -- this is setting a event that is telling when you slip on the banana you fall
- -- :Connect is telling when the event happens/triggers
- -- Touched is the event
- function hello()
- print("hello")
- end
- game.Workspace.Banana.Touched:Connect(function()
- print ("Hello")
- end )
- -- this will make the output say hello when you touched the banana
- -- you need the tie the event to the function like I just did
- -- you need to put the code in the function for it to work
- game.Workspace.Banana.Touched:Connect(function(hit)
- print (hit.Name)
- end)
- --this will print all the body parts touching the banana
- -- this is just one event
- -- you could think its a varible
- game.Workspace.Banana.Touched:Connect(function(hit)
- if game.PLayers:GetPlayerFromCharacter(hit.Parent) then
- hit.parent.Humanoid.Sit = true
- end)
- -- this script will make the player sit
- -- GetPlayerFromChracter is checking if it a actual player
- IF STATMENTS
- how to do if statments
- if 2+2 = 4 then
- print ("Correct ")
- end -- if this is is correct the output will print correct
- if false then
- print ("Correct ")
- end
- if true then
- print ("Correct ")
- end
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- end -- this is a way to check
- while wait (1) do
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- end
- end -- this is a while loop it will always check
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- else
- print("Incorrect")
- end -- if its 12 it will say correct, if it is not it will say incorret.
- Elseif and embedded if statments
- local myNumber = 3
- if myNumber % 2 == 0 then print
- print ("it's even")
- elseif myNumber 3 == 0 then
- print ("It's a multiple of 3!")
- end
- elseif myNumber % 5 == 0 then print
- print ("It's a multiple of 5!")
- else
- print ("they did all not run")
- end
- relational/conditional Operators
- all elseif symbols
- 1 > Greater than
- 2 < Less than
- 3 >= Greater than or equal to
- 4 ~= Not equal to
- 5 == equal to
- Values -BoolValues, StringValues, IntValues, etc.
- -- Values hold data you can add a Value by click the + with a circle
- -- always make sure you name your values
- -- place most values in SeverStorage
- script 1 game.SeverStorage.BoolValue.Value)
- script 2 print(game.SeverStorage.Boolvalue.Value)
- wait(5)
- game.SeverStorage.BoolValue == false
- -- StringValues only take a String
- -- CFram is a position Value -- to set a Cframe you need to do it in your script
- like this game.SeverStorage.Cfram.Value = Cfram.new (3,3,3)
- While Loops
- -- any code inside a while will repeat and repeat its self forever
- ex of a while loop
- while true do
- print ("this is cool ")
- wait(1)
- Repeating
- repeat
- print("Not enough parts in the game")
- wait()
- Until #game.Workspace.Part:GetChildren () > 1
- print("Enough parts are here ")
- end
- repeat
- print("not enough players in the game")
- wait(4)
- until
- #game.Players:GetPlayers() <= 2
- Tables (table.remove / table.insert)
- local MyVAr = game.Workspace.Baseplate
- local MyTab;e = {11,2,3,4,2,32,1,5}
- MyTable [1]-- this is game.Workspace.Baseplate
- -- tables can access data like that
- for i, v in pairs () do
- end
- local MyVAr = game.Workspace.Baseplate
- local myTable = {game.Workspace.baseplate,"tottenham",50,false}
- local playersInRound = {game.Player.Mariyan,Game.Player.John,Game.Player.Dog}
- table.remove(playersInRound,1)-- TO REMOVE A PLAYER THIS IS VERY IMPORTANT
- en
- local playerInRound - {"alvin"bob""alan"}
- print(playersInRound[2])
- Wait(2)
- table.insert(playersInRound,2,"jon")
- print(playerInRound[2])
- In pairs Loops
- local myTab = {"hello,3,4,false"}
- for i, v in pairs (MyTab) do
- print (i)
- print (v)
- end
- -- it will print hello 4 times because 4 items are in the table
- -- the reapeating is based on the items in the table
- -- the i is the index value -- the 2 item in the table
- -- the v stands for value, the value of the index -- the third 3 item in the table
- -- you need at least 3 items in the table
- local myTab = {1,2,3,4,5,6,7,8,9,10}
- print (myTab[2])
- wait ()
- for i, v in pairs (MyTab) do
- v = v * 2
- end
- local myTab - {1,2,3,4,56,7,8,9,10}
- print (myTab[2])
- wait (2)
- for i, v in pairs (myTab)
- myTab = v*2
- end
- print (myTab) [2] )
- end
- -- myTab = v*2 will double the 2 in the table thus the output saying 4 cuz 2*2= 4
- you can add any items to a table such as
- local myTab = {game.Workspace.Baseplate,game.Workspace.Terrain
- -- you can do :GetChildren() so it will take everything in the file
- local buildingsTable = game.Workspace.Buildings.GetChildren()
- local buildingsTable = {game.Workspace.Buildings.building}
- for i, v in pairs (buildingTable) do
- v:Destory() to delete
- wait (0.1)
- end
- -- it will take everything then loop through it
- -- v.Material = "Neon"
- for i, v in pairs (game.Players:GetPlayers ()) do
- v.Character.HumanoidRootPart.Position = Vector3.new( 12323.123.12.3)
- in the () you could add a position just like i did where that position is the players will spawn
- Services and Getservice()
- -- is an object and contains built in properties,functions,events
- --Services are basically like Workspace serverscript and chat
- -- only roblox makes services
- Types of services
- Main
- We can see their properies like 1 workspacce 2 CoreGui 3 Starter playe
- Other services
- -- used for handy events and lighting is one of them they are like extra details
- Example game:Getservice("Workspace")
- this will give you information about thing
- game.User(Inputservice):GetConnectedGamepads()
- you could put any service name in the Inputservice) of the code
- game:("Lighting").TimeOfDay = "23:00:00"
- how to fill a cup
- ["Decaf"] = function(Tool)
- if Tool.Name == "Cup" then
- FillCup(Tool,BrickColor.new("Pine Cone"),0,"Decaf")
- end
- types of varibles on roblox
- varibles --a way to shorten scripts/store information -- example local.
- (so you dont have to write the same thing over and over you can use local)
- varibles give access to properties
- 1 "" (string)
- 2 1331 (number)
- 3 true/false (boolean)
- 4 game.Workspace. (object reference
- print = ("dogs are cool")
- Instance.new() -- allows you to insert things into your game from a script
- Ex:Instance.new("Brick")an object goes in the()
- how to do it Instance.new("brick",)
- Instance.new(brick,) tells to put the brick in the Workspace
- local myBrick = Instance.new("brick")
- myBrick.Trapsparency = 0.5
- myBrick.Anchored = true
- myBrick.Position = Vector3.new (5,5,5) -- this is how to position
- myBrick.Parent = game.Worspace -- always have this after the properties
- Functions generatePart (name) is = to PartNumberOne
- Instance.new(brick,) tells to put the brick in the Workspace
- local myBrick = Instance.new("brick")
- myBrick.Trapsparency = 0.5
- myBrick.Anchored = true
- myBrick.Position = Vector3.new (5,5,5)
- end -- any code needs to go between the function and the end
- generatePart()-- this let you save time instead of copying 50 lines
- generatePart()-- also makes your code neatter
- generatePart()-- functions make your save time and make your code neater
- generatePart()
- generatePart()
- Function Parameter/Argruments
- generatePart("PartNumberOne")goes to name
- generatePart() -- this is the Agrument and the function is the Parameter
- generatePart()
- generatePart()
- generatePart()
- -- you need to name the part add a name in the ()
- ex:generatePart(jijij) -- jijij is the name of the brick
- Arguements pass data to the function
- function printText(stringToPrint)
- print(stringToPrint
- end
- PrintText("hello dogs")
- PrintText("robux")
- built in functions
- 5 most popular
- 1 Destroy()
- 2 Clone()
- 3 ClearAllChildren()
- 4 wait()
- 5 print()
- when you do : its calling a function
- game.Workspace.MyBrick:Destroy() -- when you run the game this script destroies the part
- local myClone = game.Workspace.Brick:Clone()
- myClone.Parent = game.Workspace
- wait(5)
- game.Workspace.MyBrick:ClearAllChildren()
- -- this script will clone the part then it will wait 5 seconds then will ClearAllChildren
- print("HELLO")
- -- print is a why to see where your script broke.
- end
- Events -- are what help things happen/trigger things
- Ex:step on a banana then you trip -- triggered that
- Example of a touched event script
- script.Parent.Touched:Connect(function(hit)
- if game.Players:GetPlayersFromCharacter(hit.Parent) then
- hit.Parent.Humanoid.Sit = true
- end
- end)
- -- this script needs to go in the object like the banana
- -- this is setting a event that is telling when you slip on the banana you fall
- -- :Connect is telling when the event happens/triggers
- -- Touched is the event
- function hello()
- print("hello")
- end
- game.Workspace.Banana.Touched:Connect(function()
- print ("Hello")
- end )
- -- this will make the output say hello when you touched the banana
- -- you need the tie the event to the function like I just did
- -- you need to put the code in the function for it to work
- game.Workspace.Banana.Touched:Connect(function(hit)
- print (hit.Name)
- end)
- --this will print all the body parts touching the banana
- -- this is just one event
- -- you could think its a varible
- game.Workspace.Banana.Touched:Connect(function(hit)
- if game.PLayers:GetPlayerFromCharacter(hit.Parent) then
- hit.parent.Humanoid.Sit = true
- end)
- -- this script will make the player sit
- -- GetPlayerFromChracter is checking if it a actual player
- IF STATMENTS
- how to do if statments
- if 2+2 = 4 then
- print ("Correct ")
- end -- if this is is correct the output will print correct
- if false then
- print ("Correct ")
- end
- if true then
- print ("Correct ")
- end
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- end -- this is a way to check
- while wait (1) do
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- end
- end -- this is a while loop it will always check
- if game.Lighting.TimeOfDay == "12:00:00 then
- print ("Correct ")
- else
- print("Incorrect")
- end -- if its 12 it will say correct, if it is not it will say incorret.
- Elseif and embedded if statments
- local myNumber = 3
- if myNumber % 2 == 0 then print
- print ("it's even")
- elseif myNumber 3 == 0 then
- print ("It's a multiple of 3!")
- end
- elseif myNumber % 5 == 0 then print
- print ("It's a multiple of 5!")
- else
- print ("they did all not run")
- end
- relational/conditional Operators
- all elseif symbols
- 1 > Greater than
- 2 < Less than
- 3 >= Greater than or equal to
- 4 ~= Not equal to
- 5 == equal to
- Values -BoolValues, StringValues, IntValues, etc.
- -- Values hold data you can add a Value by click the + with a circle
- -- always make sure you name your values
- -- place most values in SeverStorage
- script 1 game.SeverStorage.BoolValue.Value)
- script 2 print(game.SeverStorage.Boolvalue.Value)
- wait(5)
- game.SeverStorage.BoolValue == false
- -- StringValues only take a String
- -- CFram is a position Value -- to set a Cframe you need to do it in your script
- like this game.SeverStorage.Cfram.Value = Cfram.new (3,3,3)
- While Loops
- -- any code inside a while will repeat and repeat its self forever
- ex of a while loop
- while true do
- print ("this is cool ")
- wait(1)
- Repeating
- repeat
- print("Not enough parts in the game")
- wait()
- Until #game.Workspace.Part:GetChildren () > 1
- print("Enough parts are here ")
- end
- repeat
- print("not enough players in the game")
- wait(4)
- until
- #game.Players:GetPlayers() <= 2
- Tables (table.remove / table.insert)
- local MyVAr = game.Workspace.Baseplate
- local MyTab;e = {11,2,3,4,2,32,1,5}
- MyTable [1]-- this is game.Workspace.Baseplate
- -- tables can access data like that
- for i, v in pairs () do
- end
- local MyVAr = game.Workspace.Baseplate
- local myTable = {game.Workspace.baseplate,"tottenham",50,false}
- local playersInRound = {game.Player.Mariyan,Game.Player.John,Game.Player.Dog}
- table.remove(playersInRound,1)-- TO REMOVE A PLAYER THIS IS VERY IMPORTANT
- en
- local playerInRound - {"alvin"bob""alan"}
- print(playersInRound[2])
- Wait(2)
- table.insert(playersInRound,2,"jon")
- print(playerInRound[2])
- In pairs Loops
- local myTab = {"hello,3,4,false"}
- for i, v in pairs (MyTab) do
- print (i)
- print (v)
- end
- -- it will print hello 4 times because 4 items are in the table
- -- the reapeating is based on the items in the table
- -- the i is the index value -- the 2 item in the table
- -- the v stands for value, the value of the index -- the third 3 item in the table
- -- you need at least 3 items in the table
- local myTab = {1,2,3,4,5,6,7,8,9,10}
- print (myTab[2])
- wait ()
- for i, v in pairs (MyTab) do
- v = v * 2
- end
- local myTab - {1,2,3,4,56,7,8,9,10}
- print (myTab[2])
- wait (2)
- for i, v in pairs (myTab)
- myTab = v*2
- end
- print (myTab) [2] )
- end
- -- myTab = v*2 will double the 2 in the table thus the output saying 4 cuz 2*2= 4
- you can add any items to a table such as
- local myTab = {game.Workspace.Baseplate,game.Workspace.Terrain
- -- you can do :GetChildren() so it will take everything in the file
- local buildingsTable = game.Workspace.Buildings.GetChildren()
- local buildingsTable = {game.Workspace.Buildings.building}
- for i, v in pairs (buildingTable) do
- v:Destory() to delete
- wait (0.1)
- end
- -- it will take everything then loop through it
- -- v.Material = "Neon"
- for i, v in pairs (game.Players:GetPlayers ()) do
- v.Character.HumanoidRootPart.Position = Vector3.new( 12323.123.12.3)
- in the () you could add a position just like i did where that position is the players will spawn
- Services and Getservice()
- -- is an object and contains built in properties,functions,events
- --Services are basically like Workspace serverscript and chat
- -- only roblox makes services
- Types of services
- Main
- We can see their properies like 1 workspacce 2 CoreGui 3 Starter playe
- Other services
- -- used for handy events and lighting is one of them they are like extra details
- Example game:Getservice("Workspace")
- this will give you information about thing
- game.User(Inputservice):GetConnectedGamepads()
- you could put any service name in the Inputservice) of the code
- game:("Lighting").TimeOfDay = "23:00:00"
- how to fill a cup
- ["Decaf"] = function(Tool)
- if Tool.Name == "Cup" then
- FillCup(Tool,BrickColor.new("Pine Cone"),0,"Decaf")
- end
- roblox gui series
- Roblox GUI Scripting Tutorial #1 - Introduction to GUIs
- all gui are only for client and made for them
- insert gui in the StarterGui
- you need to have a screen gui as the parent of all guis
- Roblox GUI Scripting Tutorial #2 - TextButton
- local MainGui = script.Parent
- -- there is many events you could use
- local Text = MainGui.TextButton
- Text.MouseButton1Up:Connect(function()
- print("Clicked")
- end)
- Roblox GUI Scripting Tutorial #3 - TextBox
- like a search bar
- Roblox GUI Scripting Tutorial #4 - ImageLabels & ImageButtons
- You could press imageButtons but not ImageLabels
- local ScreenGui = script.Parent
- local ShopFrame = ScreenGui.ShopFrame -- Frame of the Image
- local OpenShop = ScreenGui.OpenShop -- Image
- OpenShop.MouseButton1Up:Connect(function()
- ShopFrame.Visible = not ShopFrame.Visible
- end)
- Roblox GUI Scripting Tutorial #5 - Tweening GUI
- local Inventory = script.Parent.Inventory
- local OpenInventory = script.Parent.OpenInventory
- OpenInventory.MouseButton1Up:Connect(function()
- Inventory:TweenPosition(
- UDim2.new(0.275, 0.100, 0),-- end position
- "Out",-- easing Direction
- "Quad",-- easing style
- 1,-- lengt how long it will take to open the Inventory
- false, -- override other tweens
- nil
- )
- end)
- OpenInventory.MouseButton1Up:Connect(function()
- Inventory.Position = UDim2.new(-2.75, 0.100, 0)
- end)
- Roblox GUI Scripting Tutorial #6 - UI Constraints & Layouts
- organize inventoirs with them
- Roblox GUI Scripting Tutorial #8 - Billboard GUIs
- put a billboard gui a character
- insert a textLabel in the billboard gui
- adornee it to the head
- Roblox GUI Scripting Tutorial #9 - Surface GUIs
- basically billboard guis just 1 face
- DevKing scripting
- Beginner's Roblox Scripting Tutorial #3 - Variables
- local Myname
- local HotDog = 4
- The variable is the word after the local
- like HotDog
- Beginner's Roblox Scripting Tutorial #4 - Arithmetic + Object-Oriented Programming
- print (10 + 10)
- --output will say 20
- local Baseplate = game.Workspace.Baseplate
- Baseplate.material ="Wood"
- if there is a check you need to say = true or false
- -- way to adjust properties
- Beginner's Roblox Scripting Tutorial #5 - Functions
- local function BestFunction()
- local best number = 10
- local worst number = 15
- print(BestNumber+Worst number)
- BestFunction()
- -- output will say 25
- Beginner's Roblox Scripting Tutorial #6 - Scope & Returning
- local a = 2
- local function Test1()
- print (a)
- end
- local function Test2()
- print (a)
- end
- Test1()
- Test2()
- --------------------------------------------------
- local function hi()
- print (hi)
- return "Awesome"
- end
- local Hotdog = hi()
- print(Hotdog)
- -- this will return awesome
- ----------------------------------------------
- function testReturn()
- return "This is a test!"
- end
- local returnedValue = testReturn() -- We've called the function, necessary for the functions to work.
- print(returnedValue)
- Beginner's Roblox Scripting Tutorial #7
- Beginner's Roblox Scripting Tutorial #8 - If Statements
- 3 types of if statements
- local x = 3
- if x == 3 then
- print ("Yes")
- end
- local x = 3
- local y = 9
- if x == 3 and y == 9 then
- print("Yes ")
- end
- local x = 2
- local y = 6
- if x == 3 or y == 6 then
- print("Yes ")
- -- it will print yes cuz 1 is correct
- local Baseplate = game.Workspace.Baseplate
- if Baseplate.Anchored == true then
- Baseplate.Anchored = false
- wait (2)
- Baseplate.Anchored = true
- end
- Beginner's Roblox Scripting Tutorial #9 - Else & Elseif Statements
- -- if the if statment is not true it will run a else statmente
- local Hotdogs = 3
- if Hotdogs == 3 then print ("Hotdogs is equal to 3")
- elseif
- print ("Hotdogs is not equal to 3")
- end
- Beginner's Roblox Scripting Tutorial #10 - Events
- game.Workspace.MyFavPart.Touched:Connect(function)
- -- this will see if somebody stepped on the part Touched:Connect is a way to connect the function
- Beginner's Roblox Scripting Tutorial #11 - Built-In Functions
- local melon = game.Workspace:FindFristChild("Hotdog")
- WaitForChild
- Beginner's Roblox Scripting Tutorial #12 - While and Repeat Loops
- this is a regular loop
- local hotdogs = 1
- while hotdogs < 5 do
- hotdogs = hotdogs + 1
- print ("Hello")
- print (hotdogs)
- end
- -- if hotdogs are less then five do something
- you need to do the hotdogs = hotdogs + 1 unless it will go in an infinite loop
- local hotdogs = 1
- while hotdogs < 5 do
- wait(1)
- print ("Hello")
- print (hotdogs)
- end
- local hotdogs = 1
- repeat
- ("This is from the loop")
- untile hotdogs == 3
- while hotdogs == 3 do
- print ("This is from the loop")
- end
- local hotdogs = 1
- repeat wait() until game.Players
- Beginner's Roblox Scripting Tutorial #14 - Instances
- local part = Instance.new("Part")
- part.Parent = game.Workspace
- Beginner's Roblox Scripting Tutorial #15 - Breaks / Loop Breaking
- local raindropped = 0
- while true do
- if raindropped >= 1000 then
- break
- end
- raindropped = raindropped +1
- wait()
- local Rain = Instance.new("Part",game.Workspace)
- Rain.Position = Vector3.new(0,500,5)
- Rain.Size = Vector3.new(1,1,1)
- Rain.Material = "Glass"
- Rain.Transparency = 0.50
- Rain.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild("Humanoid") then
- hit.Parent.Humanoid.Health = 0
- end
- end)
- end
- end
- Beginner's Roblox Scripting Tutorial #17 - Leaderboards / leaderstats
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder",player)
- leaderstats.Name = "leaderstats"
- local Points = Instance.new("IntValue, leaderstats")
- Points.Name = "Points"
- end)
- -- this is how to make a point giver
- script.Parent.ClickDector.MouseClick:Connect(function(player)
- local player Playerpoins = player.leaderstats.Points
- PlayerPoints.Value = PlayerPoints.Value + 1
- end)
- Beginner's Roblox Scripting Tutorial #18 - Tables
- local OmletteIngredients = {"Ham , Egg , Cheese"}
- print (Omlette Ingredient {1})-- will say ham
- print (Omlette Ingredient {2})-- will say egg
- print (Omlette Ingredient {3})-- will say cheese
- TABLE FUNCTIONS
- local OmletteIngredients = {"Ham , Egg , Cheese"}
- table.concat()-- merge them all together
- table.remove()-- will remove something from a table
- table.sort()-- will sort least to greatest only if your using numbers in a table
- table.remove,2)-- will remove egg
- table.sort(Name of number table)
- print(table.concat(OmeletteIngredients),""))
- Beginner's Roblox Scripting Tutorial #19 - in pairs loop / pairs loop
- Advanced Roblox Scripting Tutorial #1
- -- add a tool in Workspace then add a part then name it Handle
- -- put the tool in starter pack
- local Tool = script.Parent
- Tool.Activated:Connnect(function()
- local DestroyMe = game.Workspace.DestroyMe
- DestoryMe:Destroy()
- end)
- Advanced Roblox Scripting Tutorial #2 - Filtering Enabled
- nothing
- Advanced Roblox Scripting Tutorial #3 - Local Scripts
- -- only could be used in file based explorer items
- -- only the players could see that the server cant see it
- -- basically you assign it to the player only
- Advanced Roblox Scripting Tutorial #4 - Common Built-In Functions
- local Parts = game.Workspace.Parts:GetChildren()
- for i, v in pairs(Parts) do
- v:Destroy()
- wait(1)
- end
- --make a folder with 3 parts in it put in Workspace this will destroy th
- will get all children and create a table using the children
- ----------------------------------------------------------
- local character = game.Worksapce:WaitForChild("mariyandog999)
- will wait for mariyandog999 to join then will run the lines of codes
- you could write 2 parameter in the () Ex:("Part", True)
- ------------------------------------------------------------
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- -- you need to write that code for you do anything including the repStorage
- -- service is the major things with properties (like Chat, Workspace,Lighting, ServerS
- -- there is also small services like Gamepass service
- -- GetService() will see if its there if it is not there it will create it for you
- The PlayerAdded event fires when a player enters the game. This is used to fire an event when a player joins a game, such as loading the player’s saved GlobalDataStore data.
- -----------------------------------------------
- local Part = game.Workspace.Part
- Part:Clone()
- Part.Parent = workspace
- this will clone a part
- ---------------------------------------------------------
- Advanced Roblox Scripting Tutorial #5 - Mouse (Beginner to Pro 2019)
- you need to use a local script to get the mouse and in StarterPack
- local player = game.Players.LocalPlayer -- way to get your player find who he is
- local mouse = player:GetMouse()--
- mouse.Button1Down:Connect(function()
- print("player clicked mouse")
- end
- local player = game.Players.LocalPlayer -- way to get your player find who he is
- local mouse = player:GetMouse()--
- mouse.Move:Connect(function()
- print(mouse.Target)
- end)
- Advanced Roblox Scripting Tutorial #5.5 - Roblox Dev Forum & Wiki
- this just simply just a place for scripting and news for roblox
- Advanced Roblox Scripting Tutorial #6 - UserInputService (Beginner to Pro 2019)
- its like when a player presses a key
- Input is like if i press C or space that is input
- The primary purpose of this service is to allow for games to cooperate with multiple forms of available input - such as gamepads, touch screens, and keyboards. It allows a LocalScript to perform different actions depending on the device, and in turn, helps developers provide the best experience for the end user.
- The UserInputService is a service used to detect and capture the different types of input available on a user’s device.
- - create a local script then put it in starterplayerscripts
- https://developer.roblox.com/en-us/api-reference/class/UserInputService
- copy and paste that link to learn more about UserInputService
- UserInPutServoce = game:GetService("UserInPutService")
- UserInPutService.InputBegan:Connect(function(input,gameProccesedEvent)
- if input.KeyCode == Enum -- is like a list touchInput,KeyboardInput).KeyCode.A then --you could put any key in the spot i typed A
- print("Player pressed A")
- end
- end)
- -- enum is like a array of datas which you can choose from
- ------------------------------------------
- gameProcessedEvent is like if I make a giu and i click it the ourput will say true , but false if i am interacting with just the air
- ----------------
- if UserInputService.KeyBoardEnabled then
- print("you have a mouse connected")
- end
- if UserInputService.TouchEnabled then
- print("you have a touch screen connected")
- end
- if UserInputService.GamepadEnabled then
- print("you have a gamepad screen connected")
- if UserInputService.MouseEnabled then
- print("you have a mousescreen connected")
- Advanced Roblox Scripting Tutorial #7 - CFrame (Beginner to Pro 2019)
- -- Cframe is data you use to rotate positio 3rd objects
- -- stores position and orientation in 1
- local part = script.Parent
- print(part.Cframe)
- -------------
- local Part = script.Parent
- local NewCframe = Cframe.new(0,10,0)
- Part.Cframe = part.Cframe * NewCframe
- Advanced Roblox Scripting Tutorial #8 - Remote Events & Remote Functions
- use DeletePart-- name of remoteEvent:FireServer(Part--parameter you are using on) will fire the remote event
- -- they are used to let scripts on the server and local scripts on the client communicate
- SomeLocalScript ~~~~~~~ RemoteEvent ~~~~~~ SomeServerScript
- -- make a remote Event in RepStorage so clients and workspace can access it name it DeletePart and add a Part in the workspace
- -- IF YOU DONT USE REMOTE EVENTS LOCAL SCRIPTS WILL ONLY FIRE FOR 1 PLAYER
- -- remote events transfer data from local scripts to the RemoteEvent itself and finally will traverse the data to some a ServerScript
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")-- this line of code will wait for the DeletePart
- local UIS = game:GetService("UserInputService")
- local Part = game.Workspace.Part
- UIS.InputBegan:Connect(function(input, gameProcessedEvent)
- if input.KeyCode == Enum.KeyCode.Delete then -- if players clicks the delete key on thier keyboard the print will fire
- print("Delete Key was pressed")
- DeletePart:FireServer(Part)
- end
- end)
- -- NOW I AM MAKING another script
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
- DeletePart.OnServerEvent:Connect(function(player, part)-- this line of code will see if the Delete:FireServer(Part) script ran if it ran this line of code will fire and go on.OnServerEvent is a normal event , but you need to put player as the first parameter and the second parameter will be the Part in the workspace cuz we are deleting that part.
- Part:Destroy()
- end)
- ------------------------------------------------------------
- Now Remote Functions
- DeletePartFunction-- name of remoteFunction:InvokedServer(Part)
- -----------------------------------------------------------
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local DeletePart = ReplicatedStorage:WaitForChild("DeletePart")
- local Part = game.Workspace.Part
- local UIS = game:GetService("UserInputService")
- UIS.InputBegan:Connect(function(input, gameProcessedEvent)
- if input.KeyCode == Enum.KeyCode.Delete then
- print("player pressed delete key")
- DeletePart:OnServerInvoked(Part)
- end
- end)
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local DeletePartFunction = game.ReplicatedStorage:WaitForChild("DeletePartFunction")
- DeletePart.OnServerInvoked = function(player, Part
- Part:Destroy()
- end)
- Advanced Roblox Scripting Tutorial #9 - Welding (Beginner to Pro 2019)
- -- welding is basically just making 2 parts move
- - if 1 part moves then part 2 will move
- [to weld go Model < View < then click create and then click weld
- local bluePart = script.Parent
- bluePart.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild("Humanoid") then
- local head = hit.Parent.Head
- bluePart.CFrame = head.CFrame * CFrame.new(0,10,0)
- local weld = Instance.new("Weld")
- weld.Part0 = head
- weld.Part1 = bluePart
- weld.C0 = head.CFrame:Inverse()
- weld.C1 = bluePart.CFrame:Inverse()
- weld.Parent = script.Parent
- end
- end)
- Advanced Roblox Scripting Tutorial #10 - TweenService / Tween (Beginner to Pro 2019)
- -- Tweening makes parts bigger and bigger as time goes on
- -- will change properties slowly of an object
- local TweenService = game:GetService("TweenService")
- local Part = script.Parent
- local Info = TweenInfo.new(
- 10, --Lenght(seconds)
- Enum.EasingStyle.Sine,
- Enum.EasingDirection.Out,
- 2,-- how much times you want it to do, --(reapet)
- false, -- Reverse(when ever you make it super big it will go back to normal
- 1 -- delay between each tween(seconds)
- )
- local Goals =
- {
- Size = Vector3.new(15,15,15);
- }
- local MakePartBiggerTween = TweenService:Create(Part,Info,Goals)
- MakePartBiggerTween:Play()-- Play is the built in function used to play the tween
- wait(10)
- [the parameters mean]
- - what you want to tween
- -how do you want to do or how will the tween act
- -What is the thing you want to achieve
- -- don't put a comma at the end
- {there is 3 EasingDirections}
- - In
- -Out
- -InOut
- {there is 8 EasingStyles}
- they determine how the tweening acts
- -Linear
- -Sine
- -Back
- -Quaf
- -Quart
- -Quint
- -Bounce
- -Elastic
- L
- E
- E
- T
- R
- D
- Advanced Roblox Scripting Tutorial #11 - Module Scripts & Dictionaries
- you could write code in a module and call it from another
- local Dictionary = {
- Cheese = "Cows",
- Bread = "Wheat"
- }
- print(Dictionary.Cheese)
- will print ("cow")
- -------------------------------------------
- insert module script in serverstorage
- local module = { -- the module table
- Dogs = "Cute, four-legged animals that love you"
- Cats = "Mean, four-legged animals that kill"
- }
- return module
- -- go to a script in workspace and type
- local AnimalTable = require(game.ServerStorage.ModuleScript)-- require means get the table
- print(AnimalTable.Dogs)
- -----------------------------------------------------------------------------------------
- Advanced Roblox Scripting Tutorial #12 - Lerp / Lerping
- You could move a part like 20% of the way
- local Part1 = game.Workspace.Part1
- local Part2 = game.Workspace.Part2
- for i = 0,1.01 do
- wait()
- Part1.CFrame = Part1.Cframe:Lerp(Part.Cframe, .5
- end
- Advanced Roblox Scripting Tutorial #13 - Data Store / Saving Player Data
- ---------------------------------------------------
- local DataStore = game:GetService("DataStoreService")
- local MyDataStore = DataStore:GetDataStore("MyDataStore")
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local Cash = Instance.new("IntValue")
- Cash.Name = "Cash"
- Cash.Parent = leaderstats
- local PlayerId = "Player_"..player.UserId
- local data
- local success, errormessage = pcall(function()
- data = MyDataStore:GetAsync(PlayerId)-- your are storing the data in the player's user id
- end)-- GetAsync is a built in function that will load data and communicates with the data store which
- if success then
- Cash.Value = data
- end
- end)
- game.Players.PlayerRemoving:Connect(function(player)-- when a player gets removing the game will safe what he had in his leaderstats
- local PlayerId = "Player_"..player.UserId
- local data = player.leaderstats.Cash.Value -- will define data as what the player's leaderstats show
- local success, errormessage = pcall(function()
- MyDataStore:SetAsync(PlayerId, data)-- will Set the data that the player left with and permanent keep it on the player's Id
- end)
- if success then
- print("Everything went flawless")
- else
- print("The script completely failed")
- end
- end)
- Advanced Roblox Scripting Tutorial #14 - Animation
- insert a R15 block rig and then start animating
- when you make animation set the priority to Action
- file < export < create new < name it < copy the link < go to the page and copy the animation id
- -- you could only play animation in a local script
- make sure to put an animation in your local script
- -- paste your animation ID in your animation
- local BirdAnimation = script.BirdAnimation
- wait(10)
- local player = game.Players.LocalPlayer
- local char = player.Character
- local hum = char.Humanoid
- local BirdAnimation = hum:LoadAnimation(BirdAnimation)
- while true do
- wait(1.35)
- BirdAnimation:Play()
- end
- Advanced Roblox Scripting Tutorial #15 - Gamepasses | MarketplaceService
- copy the game pass id
- make a local script
- local MPS = game:GetService("MarketplaceService")
- local GamePassID = 17405519
- local function promptPurchase()
- local player = game.Players.LocalPlayer
- local hasPass = false
- local success, message = pcall(function()
- hasPass = MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)-- Built in function will check if the player owns the gamepass which player and which gamepass
- print(hasPass)-- if the player owns then the print will work if not then the PromptGamePassPurchase will run
- end)
- if hasPass == true then
- print("Player has it")
- else
- MPS:PromptGamePassPurchase(player, GamePassID)-- PromptGamePassPurchase will prompt the gamepass to the player
- print(player.Name)
- print(GamePassID)
- end
- end
- promptPurchase()
- -- lines 11 through 14 will see if the player has the gamepass if they don't then the player will be prompted with the gamepas
- ----------------------------------------------------
- insert a server script
- local GamePassID = 17405519
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
- local MPS = game:GetService("MarketplaceService")
- MPS.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, PurchaseSuccess)-- the Event will fire if the player click buys or cancesl when the gamepass shows up
- if PurchaseSuccess == true and purchasePassID == GamePassID then-- if the player clicked buy then you will give the sword
- print("Purchased the Pass")
- Sword.Parent = player.Character
- end
- end)
- --{ parameters of the event }
- -- 1st parameter = The Player object for whom the prompt was shown
- -- 2nd parameter = The ID number of the game pass shown in the prompt (not to be confused with an asset ID)
- -- 3rd parameter = Whether the item was successfully purchased (false for errors and cancellations)
- -----------------------------------------------
- insert another script in script storage
- local GamePassID = 17405519
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Sword = ReplicatedStorage:WaitForChild("ClassicSword")
- local MPS = game:GetService("MarketplaceService")
- game.Players.PlayerAdded:Connect(function(player)
- wait(1)
- local char = game.Workspace:FindFirstChild(player.Name)
- local hasPass = false
- local success, errormessage = pcall(function()
- hasPass = MPS:UserOwnsGamePassAsync(player.UserId, GamePassID)
- end)
- if success == true then
- print("player has the sword gamepass")
- Sword.Parent = char
- end
- end)
- Advanced Roblox Scripting Tutorial #16 - Developer Products
- -- same thing as gamepass just you could buy them mutliple times
- insert a local script
- local MPS = game:GetService("MarketplaceService")
- local Player = game:GetService("Players")
- local ProductID = 1169157152
- local player = game.Players.LocalPlayer
- MPS:PromptProductPurchase(player, ProductID)
- ----------------------------------------------------
- local MPS = game:GetService("MarketplaceService")
- local ProductID = 1169157152
- local players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local sword = game.ReplicatedStorage:WaitForChild("ClassicSword")
- local productID2 = 92341432
- local function processReceipt(receiptInfo)
- local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
- if not player then
- -- 2312312
- return Enum.ProductPurchaseDecision.NotProcessedYet
- end
- if receiptInfo.ProductId == ProductID then
- if player then
- local char = game.Workspace:FindFirstChild(player.Name)
- local swordClone = sword:Clone()
- swordClone.Name = "Sword"
- swordClone.Parent = char
- end
- end
- return Enum.ProductPurchaseDecision.PurchaseGranted
- end
- MPS.ProcessReceipt = processReceipt
- -- something to know is that it takes time
- example: I was confused on gamepass/marketplaceserivce then i saw the 1 one of the comments it read
- " I thought it was hard at first but after 2 days i understood it and it was easy
- Advanced Roblox Scripting Tutorial #17 - Region3
- insert a script in ServerScriptSerivce
- local region = Region3.new(Vector3.new(0,0,0), Vector3.new(15,15,15))
- local part = Instance.new("Part")
- part.Anchored = true
- part.Size = region.Size
- part.Parent = game.Workspace
- while true do
- wait()
- local PartInRegion = workspace:FindPartsInRegion3(region, part, 1000)
- for i, part in pairs(PartInRegion) do
- if part.Parent:FindFirstChild("Humanoid") ~= nil then
- print("player found in region"..part.Parent.Name)
- local char = part.Parent
- char.Humanoid:TakeDamage(char.Humanoid.MaxHealth)
- end
- end
- end
- Advanced Roblox Scripting Tutorial #18 - Math Functions
- math.floor(6.14378932749732) -- will round it to 6 rounds it to the lower value like if instead of 6.1 i wrote 6.9 it will still round it to 6
- math.ceil(6.2321412412441) -- will round it to 7
- math.huge() -- will get the highest number
- math.rad()-- coverts degrees to radian used in Cframe
- math.pi()
- math.pow(5,2) -- exponents will do 5 times five
- math.abs(50) gives absolute value
- --------------------------------------------------
- Advanced Roblox Scripting Tutorial #19 - Sounds and Music
- insert a script in serverscriptstorage
- local Sound = game.Workspace.Sound
- Sound:Play()
- Sound:Pause()
- -------------------------------------------
- Advanced Roblox Scripting Tutorial #20 - Bindable Functions
- insert a bindable function in repStorage -- name it GetList
- insert a script in serverscriptservice
- local GetList = game.ReplicatedStorage:WaitForChild("GetList")
- local banList = {"UseCode_RainWay, UseCode_Tap"}
- GetList.OnInvoke = function(player)
- for i , v in pairs(banList) do
- if v == player.Name then
- print("player is in table")
- return true
- else
- print("player is not on the list")
- return false
- end
- end
- end
- --------------------
- insert another script in serverscriptservice
- local GetList = game.ReplicatedStorage:WaitForChild("GetList")
- game.Players.PlayerAdded:Connect(function(player)
- local IsPlayerBanned = GetList:Invoke(player)
- if IsPlayerBanned == true then
- player:Kick("You are banned")
- end
- Advanced Roblox Scripting Tutorial #21 - Pathfinding
- insert a character
- insert a script in the chracter
- local PFS = game:GetService("PathfindingService")
- local human = script.Parent:WaitForChild("Humanoid")
- local torso = script.Parent:WaitForChild("Torso")
- local path = PFS:CreatePath()
- path:ComputeAsync(torso.Position, game.Workspace.endingPart.Position) -- the 2 parameters are the starting a ending point where it shall start and finish
- local waypoints = path:GetWaypoints()-- creates waypoints that lead to the end
- for i, waypoints in pairs(waypoints) do
- local part = Instance.new("Part")
- part.Shape = "Ball"
- part.Material = "Neon"
- part.Size = Vector3.new(0.6, 0.6 , 0.6)
- part.Position = waypoints.Position + Vector3.new(0,2,0)
- part.Anchored = true
- part.CanCollide = true
- part.Parent = game.Workspace
- if waypoints.Action == Enum.PathWaypointAction.Jump then
- human:ChangeState(Enum.HumanoidStateType.Jumping)
- end
- human:MoveTo(waypoints.Position)-- if just do this then it will not work you need need to generate a path then make it move to the waypoint generated path
- human.MoveToFinished:Wait(2)
- end
- human:MoveTo(game.Workspace.endingPart.Position)
- if Enum.PathStatus.Success then
- print("The Robot Found it's way")
- else
- print("The Robot Did not find it's way")
- end
- Advanced Roblox Scripting Tutorial #22 - Magnitude (Distance)
- used to check the distance between things
- local Part2 = game.Workspace.Part2
- local mainPart = game.Workspace.mainPart
- local distance = (Part2.Position - mainPart.Position).magnitude
- print(distance)
- --------------------------------------------
- Advanced Roblox Scripting Tutorial #24 - Raycasting
- insert a part
- put a script in the part
- local part = script.Parent
- local FirstRay = Ray.new(part.Position, Vector3.new(0,50,0)) -- where you want it to start and end
- while wait(1) do
- local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(FirstRay, {part})
- if hit then
- print("Part was hit")
- else
- print("no")
- end
- end
- --------------------------------------------------------------------------------------------
- local Rep = game:GetService("ReplicatedStorage")
- local Bullet = Rep:WaitForChild("Bullet")
- local turret = script.Parent
- local FireRate = 0.5
- local BulletDamage = 10
- local BulletSpeed = 150
- local AgroDist = 100
- while wait(FireRate) do
- local target = nil
- for i, v in pairs(game.Workspace:GetChildren()) do -- will loop through the workspace then find the NPC's hum and tor
- local human = v:FindFirstChild("Humanoid")
- local torso = v:FindFirstChild("Torso")
- if human and torso and human.Health > 0 then
- if (torso.Position - turret.Position).magnitude < AgroDist then -- if it is less then 100 then it will shoot
- target = torso
- print(target)
- end
- end
- end
- if target then
- local torso = target
- turret.CFrame = CFrame.new(turret.Position, torso.Position)
- local newBullet = Bullet:Clone()
- newBullet.Position = turret.Position
- newBullet.Parent = game.Workspace
- newBullet.Velocity = turret.CFrame.LookVector * BulletSpeed
- newBullet.Touched:Connect(function(objecthit)
- local human = objecthit.Parent:FindFirstChild("Humanoid")
- if human then
- human:TakeDamage(BulletDamage)
- end
- end)
- end
- end
- --------------------------------------------------------------------
- Advanced Roblox Scripting Tutorial #25 - Teleport Service
- local TP = game:GetService("TeleportService")
- local part = script.Parent
- part.Touched:Connect(function()
- local human = hit.Parent:FindFirstChild("Humanoid")
- if human then
- local char = hit.Parent
- local player = game.Players:GetPlayerFromCharacter(char)
- TP:Teleport(-- what ever the game ID is, player)
- end
- end)
- Advanced Roblox Scripting Tutorial #26 - ContextActionServic
- -A context is simply a condition during which a player may perform some action. like holding a tool
- - make a local script
- local CAS = game:GetService("ContextActionService")
- local part = game.Workspace.Part
- local function onButtonPress()
- part.BrickColor = BrickColor.new("New Yeller")
- end
- CAS:BindAction("turnBrickYellow",onButtonPress, true, "T")
- -- will show a button for mobile
- wait(5)
- CAS:UnbindAction("turnBrickYellow")
- ---------------------------------------
- Advanced Roblox Scripting Tutorial #27 - OrderedDataStores
- local DataStore = game:GetService("DataStoreService")
- local PlayerLevels = DataStore:GetOrderedDataStore("PlayerLevels")
- local scores = {
- ["MarkGamerZobieHunter312414"] = 154,
- ["SallyWacky"] = 255,
- ["NancyPlays"] = 7,
- ["UseCodeTap"] = 57,
- ["Sus"] = 412
- }
- for player, level in pairs(scores) do
- PlayerLevels:SetAsync(player, level)
- end
- local pages = PlayerLevels:GetSortedAsync(false, 3)
- print(pages)
- while wait do
- local data = pages:GetCurrentPage()
- print(data)
- for i, v in pairs(data) do
- print(v.key)
- end
- if pages.IsFinished then
- break
- else
- print("Next")
- pages:AdvanceToNextPageAsync()
- end
- end
- -------------------------------------------------------
- Advanced Roblox Scripting Tutorial #28 - Camera Manipulation
- wait(5)
- local Cam = workspace.CurrentCamera
- local player = game.Players.LocalPlayer
- local FocusPart = game.Workspace.FocusPart
- Cam.CameraType = "Fixed"
- Cam.Focus = FocusPart.CFrame
- wait(3)
- Cam.CameraType = "Custom"
- Cam.CameraSubject = player.Character.Humanoid
- ----------------------------------------------
- Advanced Roblox Scripting Tutorial #29 - RunService
- local RunService = game:GetService("RunService")
- RunService.HeartBeat:Connect(function()
- print("Hi")
- end
- Advanced Roblox Scripting Tutorial #34 - MessagingService
- -- global server communication at the same time
- insert 2 server scripts
- local Message = game:GetService("MessagingService")
- Message:SubscribeAsync("PlayerFoundItemAnnouncement", function(message) -- subscribe to a topic the 1st parameter is the Topic, the 2nd paramter is a function the data is being sent the function so you could put a paramter in the function to use the data later on
- print(message.Data)
- print(message.Sent)
- end)
- wait(5)
- Message:PublishAsync("PlayerFoundItemAnnouncement","Hello gamers")
- Advanced Roblox Scripting Tutorial #33 - Coroutine
- -- create threads -- like a new script
- -- you could print things at the same time
- local Thread = coroutine.create(function()
- print("Cookies")
- end)
- coroutine.resume(Thread)
- print("Ice Cream")
- -- you could stop coroutines by doing
- local NewThread = coroutine.wrap(function()
- print("Started")
- coroutine.yield()
- print("Started Again")
- NewThread()
- --------------------------------------
- OOP in Roblox #2 - Intro to Metatables
- more powerful version of a table
- you could have metamethods in the metatable
- -- metamethods are like tables
- local myTable = {2,432,44,45}
- local myMetaTable = {
- __index = function(table,index)--Fires when table[index] is indexed, if table[index] is nil. Can also be set to a table, in which case that table will be indexed.
- print("No data at this index")
- return 1 -- back up option
- end
- }
- --print(myTable[5])-- will print nil
- -- cuz there is not 4th index so it will print nil but then it could scan the metaTable and give the data from the metaTable
- setmetatable(myTable,myMetaTable)-- connecting the table to the metatable
- local MyNum = myTable[5]
- local anotherNum = MyNum * 5
- print(MyNum,anotherNum)-- instead of crashing a metable will return a default value instead
- ------------------------
- CUSTOM PROPERTIES - Roblox Attributes Tutorial
- -- allows you to have custom properties
- -- go to the properties and click AddAttributes
- local Debounce = false
- script.Parent.Touched:Connect(function(hit)
- local isPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
- if isPlayer and (not Debounce) then
- Debounce = true
- hit.Parent.Humanoid:TakeDamage(script.Parent:GetAttribute("Damage"))
- wait(2)
- Debounce = false
- end
- end)
- ROBLOX Building - How to use all Physics & Constraints - Part 1
- Attachment Constraint
- -- you could place attachments to parent a part
- Ball in Socket Constrain
- -- could allow 2 parts to rotate 2 freely when stucj together basically a cool weld, used for making advanched ligts
- Hinge Constraint
- -- allow attachments to rotate on 1 axis freely and you could create movement and velocity like a door.
- -- could use limits enabled
- Prismatic Constraint
- allows a part to slide along 1 axis, !------!
- Cylindrical Constraint
- -- same thing as Prismatic you it could just spin
- Rope Constraints
- -- basically just a rope you could attach it to a part to make it move in a rope physics
- Rod Constraints
- -- same thing just has limits enabled, but the rod is not lose stays at the same length forever will not contract
- Spring Constraints
- --aplies a force when it compress and works like a spring. could make cars with it
- Weld Constraints
- -- allows 2 parts to be weld
- NoCollision Constraints
- -- you could move parts through the part will only work with the specified part that you put the NoCollision Constraints
- ROBLOX Building - How to use all Physics & Constraints - Part 2
- most of these apply velocity and movement
- Align Orientation
- -- will apply movement make parts move and bounce like a soccer ball mostly rotate like one
- Align Position
- -- will push the parts together works like a magnet will met at the middle of constraints line
- Vector Force
- -- apply directional force, gravitional pull
- Line Force
- -- same thing as vectorForce
- Torque
- -- will find the center of the part and will add a force making the part spin
- Angular Velocity
- --apply force to part so a part has a constant Angular Velocity, you could make parts travel like this
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement