Tutorial page
This article is an intermediate tutorial.
All tutorials · Scripting tutorials
- First, open any place in Roblox Studio
- Once it is loaded, add a ScreenGui into the StarterGui node in the explorer.
- Make sure the 'ShowDevelopmentGui' checkbox is checked.
- Add a TextButton into the ScreenGui you inserted before.
- Set the TextButton's Name and Text properties to "Reset".
- Set the TextButton's XAlignment property to "Center".
- Set its position to: {0, 0}, {0.5, -10}
The position is a UDim2 position. The first table is the X and the second table is the Y. In both tables, the first number is the scale. The scale is on a scale of 0–1. Halfway would be 0.5, Quarter-way would be 0.25. The second number is the offset. The offset on the Y table is -10 for the TextButton to be positioned halfway on the Y axis minus 10 pixels. - Set its size to: {0.1, 0}, {20, 0}
- Set the BackgroundColor3 to any color you like.
- Set the TextColor3 to any color you like (make sure it stands out from the background color.)
- Add a LocalScript to the TextButton.
- Double-click the LocalScript. Copy and paste this in:
--!strict local Players = game:GetService("Players") local function onActivated(inputObject: InputObject, clickCount: number): () local player: Player? = Players.LocalPlayer if player and player.Character then local humanoid: Humanoid? = player.Character:FindFirstChildOfClass("Humanoid") if humanoid then -- Set the health instead of using take damage to ignore force fields humanoid.Health = 0 end end end script.Parent.Activated:Connect(onActivated)
- Try it out!