Roblox Studio Scripts

Basic Scripts

Script: Damage Block

Intructions: 

Step 1. Place a Part in Your Workspace

Step 2. Insert a Script

Step 3. Write this code Below Me


script.Parent.Touched:Connect(function(h) --h means hit

          local Humanoid = h.Parent:FindFirstChild("Humanoid") -- Finds The Humanoid

          if Humanoid then -- If the Humanoid Exists then...

                 Humanoid:TakeDamage(10)  --Change 10 to a Number of your Choice       

          end

end)

Script: Play Sound if the Tool is Equipped

Intructions:

Step 1. Insert A Tool

Step 2. Insert A Localscript

Step 3. Insert A Part in the Tool

Step 4. Name the Part: Handle

Step 5. Insert A Sound In the Handle

Step 6. Set the Sound ID to any Number you want

Step 7. Write this code Below Me


script.Parent.Equipped:Connect(function()

        script.Parent.Handle.Sound:Play() -- If You Got An Other Name for the Sound Replace Sound with the New Name!

end)

GUI Scripts

Open A Frame

Intructions:

Step 1. Insert A ScreenGui In the StarterGui

Step 2. Insert A Frame To The ScreenGui

Step 3. Insert A Button To The ScreenGui

Step 4. Insert A Localscript And Write this Code Below me


script.Parent.Frame.Visible = false -- Sets The Visibility to false


script.Parent.MouseButton1Click:Connect(function()

        script.Parent.Frame.Visible = True -- Sets the Visibility To True

end)