Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create a table to store the model names and sizes
- local modelNames = {
- ["WoodenBird"] = Vector3.new(0.5304766297340393, 0.5304766297340393, 4.266228675842285),
- ["Cat"] = Vector3.new(0.1646299660205841, 0.4369331896305084, 2.0044968128204346),
- ["Shark"] = Vector3.new(0.1646299660205841, 0.4369331896305084, 2.0044968128204346),
- ["Moon"] = Vector3.new(0.9786123037338257, 0.44974008202552795, 0.21551764011383057)
- }
- -- Create a function to check if a model has a matching size
- local function checkSize(model)
- local size = model.Size
- for name, value in pairs(modelNames) do
- if size == value then
- return name -- Return the model name if the size matches
- end
- end
- return nil -- Return nil if no match is found
- end
- -- Create a function to create and update a text object for a model
- local function createText(model)
- local text = Drawing.new("Text") -- Create a new text object
- text.Visible = false -- Set the visibility to false initially
- text.Color = Color3.new(1, 1, 1) -- Set the color to white
- text.Outline = true -- Set the outline to true
- text.OutlineColor = Color3.new(0, 0, 0) -- Set the outline color to black
- text.Center = true -- Set the center to true
- text.Size = 20 -- Set the size to 20
- -- Create a function to update the text object
- local function updateText()
- local headPos = model.Head.Position -- Get the head position of the model
- local screenPos, visible = workspace.CurrentCamera:WorldToScreenPoint(headPos) -- Convert the world position to screen position and check if it is visible
- if visible then -- If the model is visible on the screen
- text.Visible = true -- Set the text visibility to true
- text.Position = Vector2.new(screenPos.X, screenPos.Y - 50) -- Set the text position above the model's head
- local modelName = checkSize(model) -- Check the model's size and get the name
- if modelName then -- If the model has a matching name
- text.Text = modelName -- Set the text content to the name
- else -- If the model does not have a matching name
- text.Text = "Unknown" -- Set the text content to "Unknown"
- end
- else -- If the model is not visible on the screen
- text.Visible = false -- Set the text visibility to false
- end
- end
- updateText() -- Call the update function once
- -- Connect the update function to the RenderStepped event of RunService
- game:GetService("RunService").RenderStepped:Connect(updateText)
- end
- -- Loop through all models in workspace.Model.HandModel and create a text object for each one
- for _, model in pairs(workspace.Model.HandModel:GetChildren()) do
- createText(model)
- end
- -- Check if there is a MiningDrill in workspace.Ignore and create a text object for it if it exists
- local miningDrill = workspace.Ignore:FindFirstChild("MiningDrill")
- if miningDrill then
- createText(miningDrill)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement