So every new concept I learn for coding in Lua (Roblox script language I'll put
here
----Lua things----
--create variable--
word = "hello"
--if else--
if true then
print("1")
elseif false then
print("2")
else
print("3")
end
--while loop--
while true do
print()
end
--for loop--
for i = 1, 5 do
print(i)
end
--print--
print("Hello world!")
--wait function--
wait(5)
--create function--
function example()
--function w/ param--
function send(message)
print(message)
end
send ("hello")
--function w/ returning--
function getMessage()
return "hello"
end
print(getMessage())
----Roblox things----
--change brick color--
[Link] = [Link]("Black")
--change color through RGB--
[Link] = [Link](255, 255, 255)
--change brick transparency--
[Link] = 1
--get player name--
[Link]
--check if thing exists--
[Link]:FindFirstChild("MyPart")
--wait for a child to be loaded before checking--
[Link]:WaitForChild("MyPart").CanCollide = true
--Move brick--
[Link] = [Link] * [Link](0, 0, 1)
wait()
--get position--
[Link]
--set position--
[Link] = [Link](0, 0, 0)
--Create new object: (type, parent)--
[Link]("Part", [Link])
--bool check what kind of object--
[Link].Part1:IsA("Part")
--destroy object--
[Link].Part1:Destroy()
--create clone--
part = [Link]:Clone()
[Link] = [Link]
--Check if a string contains something--
if [Link](myString, "hello") then
--Set velocity--
[Link] = [Link](0,0,0)
--User inputs--
local UserInput = game:GetService("UserInputService")
[Link]:Connect(function(input, gameProcessedEvent)
if [Link] == [Link].W then
print("W PRESSED")
end
end)
----UI STUFF----
--Hovering--
[Link]:Connect(function()
print("Mouse is hovering above")
end)
--leaving--
[Link]:Connect(function()
print("Mouse is no longer hovering")
end)
--clicking--
[Link].MouseButton1Click:Connect(function()
print("Button clicked")
end)
[Link]:SetCoreGuiEnabled()
[Link]
local Players = game:GetService("Players")
function showPos(vector)
local player = [Link]
local character = [Link]
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if [Link]:GetTouchingParts() ~= "" then
[Link] = vector
end
wait()
end
--kill brick--
[Link]:connect(function(hit)
if [Link]:FindFirstChild("Humanoid") then
[Link] = 0
end
end)
d3 moving platform 10:38
while true do
for i = 1, 20 do
[Link] = [Link] * [Link](0, 0, -0.5)
showPos([Link](0, 0, -0.5))
end
for i = 1, 20 do
[Link] = [Link] * [Link](0, 0.5, 0)
showPos([Link](0, 0.5, 0))
end
for i = 1, 20 do
[Link] = [Link] * [Link](0, 0, 0.5)
showPos([Link](0, 0, 0.5))
end
for i = 1, 20 do
[Link] = [Link] * [Link](0, -0.5, 0)
showPos([Link](0, -0.5, 0))
end
end