0% found this document useful (0 votes)
378 views4 pages

Roblox Studio Scripting Guide

The document provides a collection of Lua and Roblox scripting examples, including variable creation, control structures (if-else, loops), function definitions, and object manipulation within the Roblox environment. It covers changing properties of game objects, handling user input, and implementing UI interactions. Additionally, it demonstrates how to check for object existence and manage player interactions in a game setting.

Uploaded by

olkiyos9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
378 views4 pages

Roblox Studio Scripting Guide

The document provides a collection of Lua and Roblox scripting examples, including variable creation, control structures (if-else, loops), function definitions, and object manipulation within the Roblox environment. It covers changing properties of game objects, handling user input, and implementing UI interactions. Additionally, it demonstrates how to check for object existence and manage player interactions in a game setting.

Uploaded by

olkiyos9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

----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)

You might also like