0% found this document useful (0 votes)
15 views

Detailed Python Roblox Lua Tutorials

Uploaded by

alihazem201111
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Detailed Python Roblox Lua Tutorials

Uploaded by

alihazem201111
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

# Python Tutorials

## Basics

### Variables and Data Types


Python supports various data types like integers, floats, strings, and booleans.

```python
# Example
x = 10 # Integer
y = 3.14 # Float
name = "Ali" # String
is_active = True # Boolean

print(f"My name is {name} and I am {x} years old.")


```

### Input and Output


Take input from users and display output.

```python
# Example
name = input("Enter your name: ")
print(f"Hello, {name}!")
```

### Conditional Statements


```python
# Example
age = int(input("Enter your age: "))
if age < 18:
print("You are a minor.")
elif age == 18:
print("You just became an adult!")
else:
print("You are an adult.")
```

### Loops
```python
# Example
# For loop
for i in range(5):
print(f"Iteration {i}")

# While loop
count = 0
while count < 5:
print(f"Count is {count}")
count += 1
```

### Functions
```python
# Example
def greet(name):
return f"Hello, {name}!"
print(greet("Ali"))
```

## Intermediate

### File Handling


```python
# Example
with open("example.txt", "w") as file:
file.write("Hello, this is a test file!")

with open("example.txt", "r") as file:


content = file.read()
print(content)
```

### Object-Oriented Programming


```python
# Example
class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model

def start(self):
print(f"The {self.brand} {self.model} is starting!")

my_car = Car("Tesla", "Model X")


my_car.start()
```

## Advanced

### APIs
```python
# Example
import requests

response = requests.get("https://api.github.com")
print(response.json())
```

---

# Roblox Lua Tutorials

## Basics

### Variables and Data Types


```lua
-- Example
local playerName = "Ali"
local playerScore = 100
local isAlive = true

print("Player Name:", playerName)


```

### Functions
```lua
-- Example
function greetPlayer(name)
return "Welcome, " .. name .. "!"
end

print(greetPlayer("Ali"))
```

### Loops
```lua
-- Example
for i = 1, 5 do
print("Iteration " .. i)
end

local count = 0
while count < 5 do
print("Count: " .. count)
count = count + 1
end
```

## Roblox Studio Specific

### Events
```lua
-- Example
local part = script.Parent

part.Touched:Connect(function(hit)
print("The part was touched by: " .. hit.Name)
end)
```

### GUI Scripting


```lua
-- Example
local button = script.Parent

button.MouseButton1Click:Connect(function()
print("Button clicked!")
end)
```

## Game Development Topics

### Animations
```lua
-- Example
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://123456789"

local humanoid = game.Workspace.Player.Humanoid


local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
```

### Monetization
```lua
-- Example
game.MarketplaceService:PromptPurchase(player, 12345678)
```

You might also like