ok so it does pop up and whatever you hover but i want the clone to pop up when you…
- User
ok so it does pop up and whatever you hover but i want the clone to pop up when you actually click on the worker. Also, the highlights only pop up on the part of the worker the mouse is on, i want it to cover the whole model when hovering. My script: -- Services local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService")
-- Variables local player = Players.LocalPlayer local tool = script.Parent local deleteToolGui = ReplicatedStorage:WaitForChild("DeleteToolGui") local currentTarget = nil local currentGuiInstance = nil
-- Functions local function showHighlight(part) if not part then return end local highlight = Instance.new("Highlight") highlight.FillTransparency = 0.7 highlight.OutlineTransparency = 0.1 highlight.OutlineColor = Color3.new(1, 0, 0) -- Orange highlight.Parent = part return highlight end
local function hideHighlight(part) if part and part:FindFirstChild("Highlight") then part:FindFirstChild("Highlight"):Destroy() end end
local function showGui(character) if not character or not character:FindFirstChild("Torso") then return end if currentGuiInstance then currentGuiInstance:Destroy() end
local guiClone = deleteToolGui:Clone() guiClone.Parent = character.Torso currentGuiInstance = guiClone -- Set up buttons local deleteButton = guiClone.Buttons:WaitForChild("DeleteButton") local pickupButton = guiClone.Buttons:WaitForChild("PickupButton") deleteButton.MouseButton1Click:Connect(function() -- **DELETE LOGIC HERE** (e.g., call RemoteEvent) print("Delete clicked!") hideHighlight(currentTarget) if currentGuiInstance then currentGuiInstance:Destroy() currentGuiInstance = nil end end) pickupButton.MouseButton1Click:Connect(function() -- **PICKUP LOGIC HERE** (e.g., call RemoteEvent) print("Pickup clicked!") hideHighlight(currentTarget) if currentGuiInstance then currentGuiInstance:Destroy() currentGuiInstance = nil end end)end
local function hideGui() if currentGuiInstance then currentGuiInstance:Destroy() currentGuiInstance = nil end end
-- Main Loop for Raycasting local function onHeartbeat() if not tool.Parent or tool.Parent ~= player.Character then return end
local mouse = player:GetMouse() local target = mouse.Target local character = mouse.Target and mouse.Target.Parent -- Check if hovering over a worker model if character and character:FindFirstChild("WorkerConfig") then -- Adjust "WorkerConfig" to your identifier if currentTarget ~= target then hideHighlight(currentTarget) currentTarget = target showHighlight(currentTarget) showGui(character) end else hideHighlight(currentTarget) currentTarget = nil hideGui() endend
-- Connections tool.Equipped:Connect(function() RunService.Heartbeat:Connect(onHeartbeat) end)
tool.Unequipped:Connect(function() hideHighlight(currentTarget) hideGui() RunService.Heartbeat:Disconnect(onHeartbeat) end)
Assistant