xvc200

custom_cursor

Jul 26th, 2025
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. local UserInputService = game:GetService("UserInputService")
  2. local RunService = game:GetService("RunService")
  3. local Players = game:GetService("Players")
  4. local LocalPlayer = Players.LocalPlayer
  5.  
  6. --protectui
  7. function protectUI(sGui)
  8. local function blankfunction(...)
  9. return ...
  10. end
  11.  
  12. local cloneref = cloneref or blankfunction
  13.  
  14. local function SafeGetService(service)
  15. return cloneref(game:GetService(service)) or game:GetService(service)
  16. end
  17.  
  18. local cGUI = SafeGetService("CoreGui")
  19. local rPlr = SafeGetService("Players"):FindFirstChildWhichIsA("Player")
  20. local cGUIProtect = {}
  21. local rService = SafeGetService("RunService")
  22. local lPlr = SafeGetService("Players").LocalPlayer
  23.  
  24. local function NAProtection(inst, var)
  25. if inst then
  26. if var then
  27. inst[var] = "\0"
  28. inst.Archivable = false
  29. else
  30. inst.Name = "\0"
  31. inst.Archivable = false
  32. end
  33. end
  34. end
  35.  
  36. if (get_hidden_gui or gethui) then
  37. local hiddenUI = (get_hidden_gui or gethui)
  38. NAProtection(sGui)
  39. sGui.Parent = hiddenUI()
  40. return sGui
  41. elseif (not is_sirhurt_closure) and (syn and syn.protect_gui) then
  42. NAProtection(sGui)
  43. syn.protect_gui(sGui)
  44. sGui.Parent = cGUI
  45. return sGui
  46. elseif cGUI:FindFirstChildWhichIsA("ScreenGui") then
  47. pcall(function()
  48. for _, v in pairs(sGui:GetDescendants()) do
  49. cGUIProtect[v] = rPlr.Name
  50. end
  51. sGui.DescendantAdded:Connect(function(v)
  52. cGUIProtect[v] = rPlr.Name
  53. end)
  54. cGUIProtect[sGui] = rPlr.Name
  55.  
  56. local meta = getrawmetatable(game)
  57. local tostr = meta.__tostring
  58. setreadonly(meta, false)
  59. meta.__tostring = newcclosure(function(t)
  60. if cGUIProtect[t] and not checkcaller() then
  61. return cGUIProtect[t]
  62. end
  63. return tostr(t)
  64. end)
  65. end)
  66. if not rService:IsStudio() then
  67. local newGui = cGUI:FindFirstChildWhichIsA("ScreenGui")
  68. newGui.DescendantAdded:Connect(function(v)
  69. cGUIProtect[v] = rPlr.Name
  70. end)
  71. for _, v in pairs(sGui:GetChildren()) do
  72. v.Parent = newGui
  73. end
  74. sGui = newGui
  75. end
  76. return sGui
  77. elseif cGUI then
  78. NAProtection(sGui)
  79. sGui.Parent = cGUI
  80. return sGui
  81. elseif lPlr and lPlr:FindFirstChild("PlayerGui") then
  82. NAProtection(sGui)
  83. sGui.Parent = lPlr:FindFirstChild("PlayerGui")
  84. return sGui
  85. else
  86. return nil
  87. end
  88. end
  89.  
  90. --getgenv settings
  91. getgenv().CustomCursorEnabled = getgenv().CustomCursorEnabled or false
  92. getgenv().imagesize = getgenv().imagesize or {46, 46}
  93. getgenv().imageid = getgenv().imageid or "id"
  94.  
  95. local Cursor = Instance.new("ScreenGui")
  96. Cursor.Name = "CustomCursor"
  97. Cursor.IgnoreGuiInset = true
  98. Cursor.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  99. Cursor.ResetOnSpawn = false
  100. protectUI(Cursor)
  101.  
  102. local CursorImage = Instance.new("ImageLabel")
  103. CursorImage.Name = "CursorImage"
  104. CursorImage.AnchorPoint = Vector2.new(0.5, 0.5)
  105. CursorImage.BackgroundTransparency = 1
  106. CursorImage.Size = UDim2.fromOffset(getgenv().imagesize[1], getgenv().imagesize[2])
  107. CursorImage.Image = "http://www.roblox.com/asset/?id=" .. getgenv().imageid
  108. CursorImage.ZIndex = 999
  109. CursorImage.Visible = false
  110. CursorImage.Parent = Cursor
  111.  
  112. local RenderConnection
  113.  
  114. local function ToggleCustomCursor(enabled)
  115. getgenv().CustomCursorEnabled = enabled
  116. local oldMouseIcon = UserInputService.MouseIconEnabled
  117.  
  118. if enabled then
  119. RenderConnection = RunService.RenderStepped:Connect(function()
  120. UserInputService.MouseIconEnabled = false
  121.  
  122. local mouseLocation = UserInputService:GetMouseLocation()
  123. CursorImage.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
  124. CursorImage.Visible = true
  125. end)
  126. else
  127. if RenderConnection then
  128. RenderConnection:Disconnect()
  129. end
  130. UserInputService.MouseIconEnabled = oldMouseIcon
  131. CursorImage.Visible = false
  132. end
  133. end
  134.  
  135. ToggleCustomCursor(getgenv().CustomCursorEnabled)
  136.  
  137. getgenv().ToggleCustomCursor = ToggleCustomCursor
  138.  
  139. return {
  140. Toggle = ToggleCustomCursor,
  141. Cursor = CursorImage
  142. }
Advertisement
Add Comment
Please, Sign In to add comment