Who wants a tutorial script? Here it is : (This is script number 1)
Asked by
5 years ago Edited 5 years ago
--[[ Welcome to my begginer script!
You may take what ever you need.
SharkOwen09 --]]
-- 1: Making code shorter (Using "LOCAL" (Varabie = local) --
-- Varabies --
local light1 = game.Workspace.GameParts.Light1
local light2 = game.Workspace.GameParts.Light2
-- Effects --
light1.PointLight.Range = 0
light2.PointLight.Range = 0
-- 2+3+4: Adding a part + looping + Parameters / Arguments --
function generatepart(name,isAnchored,Trans)
local part = Instance.new("Part")
part.Name = name
part.BrickColor = BrickColor.new("Really red")
part.Anchored = isAnchored
part.Position = Vector3.new(0,15,0)
part.Size = Vector3.new(5,5,5)
part.Parent = workspace
part.Transparency = Trans
end
generatepart("PartNumberOne",true,0)
generatepart("PartNumberTwo",false,0.3)
-- Examp 2 (YOU NEED OUTPUT TO SEE THESE MESSAGES) --
function printText(STP)
print(STP)
end
printText("100x100 is 10,000")
printText("100x100 is not 27,928")
-- 5: Returning (It stops function)--
function addNumbers(number1,number2)
local result = number1+number2
return result
end
local calculateResult = addNumbers(8,5) -- 13
print(calculateResult*89) -- Now 1,157 --
-- Examp 2 --
function CP(trans,color,anchor)
local part = Instance.new("Part")
part.Transparency = trans
part.Color = color
part.Anchored = anchor
part.Parent = workspace
return part
end
local MRP = CP(0.5,Color3.fromRGB(255,0,0),true)
MRP.Color = Color3.fromRGB(0,255,0)
-- Final: Built in functions
-- Clone --
local myClone = game.Workspace.GameParts.Light1:Clone()
myClone.parent = game.Workspace
-- ClearAllChildren --
game.Workspace.GameParts.Light1:ClearAllChildren()
-- you should know how to use destroy,wait, and print --