Thanks for your question :clap:, if someone gives you an answer it would be great if you thanked them with a :white_check_mark: in response. This response will earn you both points for special roles on this server.
#highlights people
5 messages · Page 1 of 1 (latest)
@glad crag kaizoa.'s Question:
i need to make a script that shows people in a white box not box something like frame and not filled with color and their health bar next to it
To assist you in creating such a script, I will provide an example using HTML5 Canvas and JavaScript. This example will create a simple representation of people within a rectangular frame with an unfilled color and display a health bar next to each person.
This example assumes that you want to draw them on a web page. Save the following as "health_bar.html":
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>People Frame with Health Bar</title>
<script>
window.onload = function() {
const canvas = document.getElementById('peopleCanvas');
const ctx = canvas.getContext('2d');
// A function to draw a person frame and health bar.
function drawPersonWithHealthBar(x, y, width, height, healthPercent) {
// Draw the frame for the person
ctx.beginPath();
ctx.rect(x, y, width, height);
ctx.strokeStyle = '#000000'; // frame color: black
ctx.stroke();
// Draw the health bar
const healthBarWidth = 100; // width of the health bar
const healthBarHeight = 10; // height of the health bar
const healthBarX = x + width + 10; // 10px away from the person's frame
const healthBarY = y + (height - healthBarHeight) / 2; // centered vertically to the person's frame
// Background of health bar (grey)
ctx.fillStyle = '#DDDDDD';
ctx.fillRect(healthBarX, healthBarY, healthBarWidth, healthBarHeight);
// Foreground of health bar (green for health)
ctx.fillStyle = '#00FF00';
ctx.fillRect(healthBarX, healthBarY, healthBarWidth * healthPercent, healthBarHeight);
}
// Example data for three people with different health percentages
const people = [
{ x: 50, y: 50, width: 50, height: 100, health: 0.8 }, // 80% health
{ x: 50,
y: 200, width: 50, height: 100, health: 0.4 }, // 40% health
{ x: 50, y: 350, width: 50, height: 100, health: 0.6 }, // 60% health
];
// Draw each person with their health bar
people.forEach(person => {
drawPersonWithHealthBar(
person.x,
person.y,
person.width,
person.height,
person.health,
);
});
};
</script>
</head>
<body>
<canvas id="peopleCanvas" width="800" height="600" style="border:1px solid #000000;"></canvas>
</body>
</html>
This script defines a canvas element and a drawPersonWithHealthBar function that takes parameters for position, size, and health percentage and renders a person within a frame and a corresponding health bar. The people array holds example data that you can adjust based on your needs. When the webpage with this script loads, it will draw the people with their health bars on the canvas. To see the output, simply open the HTML file in your browser.
@glad crag kaizoa.'s Question:
i need to make a script that shows people in a white box not box something like frame and not filled with color and their health bar next to it in roblox
Creating a UI in Roblox requires using the built-in Roblox Studio tools to manipulate the GUI elements. Below is a Lua script for Roblox that creates a simple UI element representing a person with a health bar next to them. It assumes that you have a LocalScript running on the client, and this script is intended to be used within a Roblox GUI (ScreenGui).
Here's a simple script that you can start with:
-- Function to create a person's frame and a health bar
function createHealthBarFrame(player, parentGui, position, size, healthPercent)
-- Create a frame for the person
local personFrame = Instance.new("Frame")
personFrame.BackgroundColor3 = Color3.new(1, 1, 1) -- White frame
personFrame.Size = size
personFrame.Position = position
personFrame.BackgroundTransparency = 1 -- Make it transparent
personFrame.Parent = parentGui
-- Create a border for the person frame
local personBorder = Instance.new("Frame")
personBorder.BackgroundColor3 = Color3.new(0, 0, 0) -- Black border
personBorder.Size = UDim2.new(1,2,1,2) -- Slightly larger to create border effect
personBorder.Position = UDim2.new(0,-1,0,-1) -- Position offset to envelop person frame
personBorder.ZIndex = personFrame.ZIndex - 1 -- Send border behind the person frame
personBorder.Parent = personFrame
-- Create the health bar
local healthBar = Instance.new("Frame")
healthBar.BackgroundColor3 = Color3.new(0, 1, 0) -- Green health bar
healthBar.Size = UDim2.new(healthPercent, 0, 1, 0) -- Size based on health percent
healthBar.Position = UDim2.new(1, 10, 0.5, -5) -- Next to person frame
healthBar.AnchorPoint = Vector2.new(0, 0.5) -- Centered vertically
healthBar.Parent = personFrame
end
-- Create ScreenGui under the Play
erGui
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
-- Create a white frame (person representation) and a health bar beside it
createHealthBarFrame(
game.Players.LocalPlayer,
screenGui,
UDim2.new(0, 100, 0, 100), -- Position on the screen
UDim2.new(0, 50, 0, 150), -- Size of the white frame
0.75 -- Health percentage (75% health)
)
Make sure to insert this Lua script into a `LocalScript` that is placed as a child of a `ScreenGui`. Open Roblox Studio and find the explorer window, then navigate to your `StarterGui`. Right-click on it and add a `ScreenGui`, then right-click on the `ScreenGui` you've created and add a `LocalScript`. Paste the Lua code into that `LocalScript`.
This script will create a white, transparent frame with a black border to represent a person, and a green health bar directly next to the frame to indicate the person's health. Adjust position, size, and health percentage per your requirements. To handle multiple players or dynamic health changes, you would need to expand upon this script and hook into the appropriate game events or data models.