Advertisement
ColdSpecs

uu

Sep 24th, 2023
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. -- Create a table to store the model names and sizes
  2. local modelNames = {
  3. ["WoodenBird"] = Vector3.new(0.5304766297340393, 0.5304766297340393, 4.266228675842285),
  4. ["Cat"] = Vector3.new(0.1646299660205841, 0.4369331896305084, 2.0044968128204346),
  5. ["Shark"] = Vector3.new(0.1646299660205841, 0.4369331896305084, 2.0044968128204346),
  6. ["Moon"] = Vector3.new(0.9786123037338257, 0.44974008202552795, 0.21551764011383057)
  7. }
  8.  
  9. -- Create a function to check if a model has a matching size
  10. local function checkSize(model)
  11. local size = model.Size
  12. for name, value in pairs(modelNames) do
  13. if size == value then
  14. return name -- Return the model name if the size matches
  15. end
  16. end
  17. return nil -- Return nil if no match is found
  18. end
  19.  
  20. -- Create a function to create and update a text object for a model
  21. local function createText(model)
  22. local text = Drawing.new("Text") -- Create a new text object
  23. text.Visible = false -- Set the visibility to false initially
  24. text.Color = Color3.new(1, 1, 1) -- Set the color to white
  25. text.Outline = true -- Set the outline to true
  26. text.OutlineColor = Color3.new(0, 0, 0) -- Set the outline color to black
  27. text.Center = true -- Set the center to true
  28. text.Size = 20 -- Set the size to 20
  29.  
  30. -- Create a function to update the text object
  31. local function updateText()
  32. local headPos = model.Head.Position -- Get the head position of the model
  33. local screenPos, visible = workspace.CurrentCamera:WorldToScreenPoint(headPos) -- Convert the world position to screen position and check if it is visible
  34. if visible then -- If the model is visible on the screen
  35. text.Visible = true -- Set the text visibility to true
  36. text.Position = Vector2.new(screenPos.X, screenPos.Y - 50) -- Set the text position above the model's head
  37. local modelName = checkSize(model) -- Check the model's size and get the name
  38. if modelName then -- If the model has a matching name
  39. text.Text = modelName -- Set the text content to the name
  40. else -- If the model does not have a matching name
  41. text.Text = "Unknown" -- Set the text content to "Unknown"
  42. end
  43. else -- If the model is not visible on the screen
  44. text.Visible = false -- Set the text visibility to false
  45. end
  46. end
  47.  
  48. updateText() -- Call the update function once
  49.  
  50. -- Connect the update function to the RenderStepped event of RunService
  51. game:GetService("RunService").RenderStepped:Connect(updateText)
  52. end
  53.  
  54. -- Loop through all models in workspace.Model.HandModel and create a text object for each one
  55. for _, model in pairs(workspace.Model.HandModel:GetChildren()) do
  56. createText(model)
  57. end
  58.  
  59. -- Check if there is a MiningDrill in workspace.Ignore and create a text object for it if it exists
  60. local miningDrill = workspace.Ignore:FindFirstChild("MiningDrill")
  61. if miningDrill then
  62. createText(miningDrill)
  63. end
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement