Loading...
Learn
Learn to build games with Studio and scripts.
Getting started
The Studio window
The 3D View shows your world. The Explorer lists every object, Properties shows the selected object, and Output shows messages from your scripts.
Moving the camera
Hold the right mouse button to turn, use the wheel to zoom, the middle button to slide, and W A S D, Q and E to fly. Shift is faster.
Adding objects
Hover over an object in the Explorer and click the plus. Search for what you want; it becomes a child of that object.
Selecting several parts
Drag with the left mouse button to draw a frame, or hold Ctrl and click. Ctrl+A selects all parts.
Part shapes
Use the arrow next to Part to add a ball, wedge, corner wedge or cylinder. The Shape property changes an existing part.
Spawn points
Players appear on parts with "Spawn point" ticked. New maps already have one called SpawnLocation.
Building a user interface
Add a ScreenGui to StarterGui and put Frames, TextLabels or TextButtons inside. Drag them to move and pull the white squares to resize. Yellow lines show the distance.
Coding
Your first script
Insert a Script. Scripts use Lua. Press Test and read the Output panel.
print("Hello world!")
Changing a part
Find a part by name in workspace and set its properties.
local part = workspace.Part part.Color = Color3.new(1, 0, 0) part.Transparency = 0.5
Reacting to touches
Touched fires when something touches a part. This one removes health, like lava.
workspace.Lava.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(10) end end)
Script or LocalScript?
A Script runs on the server and decides what really happens. A LocalScript runs for one player and handles their screen and input. RemoteEvents connect them.
Saving player data
A Script can save numbers, text and tables with DataStoreService. In Studio tests, saves only last until you stop.
local store = game:GetService("DataStoreService"):GetDataStore("Coins") game.Players.PlayerAdded:Connect(function(player) local coins = store:GetAsync(player.UserId) or 0 store:SetAsync(player.UserId, coins + 1) end)
Water and climbing
Give a part the material Water and players swim in it (Space rises). The material Truss can be climbed by walking against it. Players run with Shift.
Playing a sound
Insert a Sound into a part with the plus button, choose a file and call Play from a script.
workspace.Part.Sound:Play()
Animations
Insert an Animation and double-click it. Choose a joint, move the sliders and a keyframe appears at the current time. A LocalScript can play it.
local player = game.Players.LocalPlayer local humanoid = player.Character:WaitForChild("Humanoid") humanoid:LoadAnimation(game.ReplicatedStorage.Animation):Play()
Buttons
Put a LocalScript inside a TextButton. Its parent is the button.
script.Parent.MouseButton1Click:Connect(function() print("Clicked") end)
Sound and music
Background music
Click Music in the Studio bar. A Sound with a song from the free Flinzu library is added to Workspace; it loops and starts by itself. Choose another song in Properties and press Listen.
Sound effects
Click Sound effect, or insert a Sound into a part. The library has coins, jumps, explosions, lasers, a win sound and more. You can also upload your own MP3, OGG or WAV file.
Library sounds in a script
Every library sound has an id that starts with flinzu:. Set it as SoundId and call Play.
local sound = Instance.new("Sound") sound.SoundId = "flinzu:coin" sound.Volume = 0.8 sound.Parent = workspace sound:Play() -- Songs: flinzu:music-happy, music-adventure, music-calm, -- music-spooky, music-action, music-chill -- Effects: spawn, coin, jump, click, pop, hit, explosion, powerup, -- win, lose, laser, swoosh, ding, alarm, step, splash, magic, -- beep, thud, wind
Controlling a sound
Play, Pause, Resume and Stop work in every script. PlaybackSpeed makes it faster or slower; Looped repeats it.
local music = workspace.Music music:Pause() wait(2) music.PlaybackSpeed = 1.25 music:Resume() print(music.IsPlaying)
When a sound ends
In a LocalScript the Ended event fires when the sound has finished.
local sound = workspace.Part.Sound sound.Ended:Connect(function() print("done") end) sound:Play()
The spawn sound
Players hear a short sound when they join and every time they respawn. Each player can switch it off in the game settings.
Tools and prompts
Making a tool
Insert a Tool into StarterPack. It already has a part called Handle: that is what the player holds. Every player gets a copy in their hotbar and takes it with the keys 1 to 9.
Clicking with a tool
Put a Script inside the Tool. Activated fires when the player clicks while holding it.
local tool = script.Parent tool.Equipped:Connect(function() print("in the hand") end) tool.Activated:Connect(function() local sound = Instance.new("Sound", tool.Handle) sound.SoundId = "flinzu:swoosh" sound:Play() end)
A sword that hurts
The Handle touches what is in front of the player, so Touched works like on big game sites.
local tool = script.Parent local swinging = false tool.Activated:Connect(function() swinging = true wait(0.4) swinging = false end) tool.Handle.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if swinging and humanoid and hit.Parent ~= tool.Parent then humanoid:TakeDamage(20) end end)
Giving a tool from a script
Tools in a player's Backpack show up in their hotbar. EquipTool puts one straight into the hand.
game.Players.PlayerAdded:Connect(function(player) local tool = game.ServerStorage.Wand:Clone() tool.Parent = player.Backpack player.CharacterAdded:Wait() player.Character.Humanoid:EquipTool(tool) end)
Dropping tools
Players drop the tool in their hand with Backspace and pick tools up by walking into them. Untick CanBeDropped to keep a tool in the hand.
Press E: ProximityPrompt
Insert a ProximityPrompt into a part. Near it, players see "E" with your text. Triggered fires on the server.
local prompt = workspace.Door.ProximityPrompt prompt.ActionText = "Open" prompt.ObjectText = "Door" prompt.Triggered:Connect(function(player) workspace.Door.Transparency = 1 workspace.Door.CanCollide = false end)
Holding a prompt
Set HoldDuration and players have to hold the key; a ring fills up. MaxActivationDistance sets how close they must be.
local prompt = Instance.new("ProximityPrompt") prompt.ActionText = "Open chest" prompt.HoldDuration = 1.5 prompt.MaxActivationDistance = 8 prompt.Parent = workspace.Chest
Earning with your game
Creating a pass
Open Create, click your game and choose Passes. Copy the ID of the pass for your scripts.
Using a pass in a script
Check whether a player owns it, or open the purchase window.
local market = game:GetService("MarketplaceService") local PASS = "paste-the-id-here" game.Players.PlayerAdded:Connect(function(player) if market:UserOwnsGamePassAsync(player.UserId, PASS) then print(player.Name .. " has the pass") else market:PromptGamePassPurchase(player, PASS) end end)
Selling a developer product
Products can be bought again and again (coins, lives, boosts). Create one under Create → your game → Developer products. A Script gives it out when it is paid.
local market = game:GetService("MarketplaceService") local COINS = "paste-the-product-id-here" -- Server Script: runs once for every purchase market.ProcessReceipt = function(info) local player = game.Players:GetPlayerByUserId(info.PlayerId) if player and info.ProductId == COINS then player.leaderstats.Coins.Value += 100 end return Enum.ProductPurchaseDecision.PurchaseGranted end -- Open the purchase window, for example from a button or a ProximityPrompt market:PromptProductPurchase(player, COINS)
When a pass is bought in the game
PromptGamePassPurchaseFinished fires on the server right after the purchase, so the player gets the bonus at once and does not have to rejoin.
local market = game:GetService("MarketplaceService") local SPEED = "paste-the-pass-id-here" local function apply(player) local humanoid = player.Character and player.Character:FindFirstChild("Humanoid") if humanoid and market:UserOwnsGamePassAsync(player.UserId, SPEED) then humanoid.WalkSpeed = 28 end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() wait(0.1) apply(player) end) end) market.PromptGamePassPurchaseFinished:Connect(function(player, passId, bought) if bought and passId == SPEED then apply(player) end end)
A shop button in your game
Players pay with Sparks. A LocalScript opens the purchase window; the Flinzu games do it with their yellow Sparks shop button.
-- LocalScript in a TextButton local market = game:GetService("MarketplaceService") local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() market:PromptGamePassPurchase(player, "paste-the-pass-id-here") -- or for a product: -- market:PromptProductPurchase(player, "paste-the-product-id-here") end)
What you earn
You get 70 % of every price in Sparks. Sales arrive in your wallet after 7 days, so refunds and fraud can be checked first. Pass or product: a pass is bought once and kept forever, a product can be bought again and again.
Awarding a badge
Create the badge in your game's Badges menu and award it from a Script.
local badges = game:GetService("BadgeService") badges:AwardBadge(player.UserId, "paste-the-id-here")