I want to make an item marker that pinpoints what the item (in this case a “tool”) player is currently selecting and is ready to pick up
the position code and the spinning function are working properly but when I tried to make it
grow and shrink repeatedly while the player is still selecting it just keeps growing (see the video below)
alternatively, I see someone using the player UI to mark the item but I’m not too familiar with ScreenUI element so if you think this might be better for what I want to achieve please give me some advice
pick up code:
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local CS = game:GetService("CollectionService")
local Event = RS:FindFirstChild("PickUp")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Marker = RS:FindFirstChild("Marker"):Clone()
local maxMarkSize = "5.5,5.5,0.5"
local markSize = Marker.Size
local markerParent = nil
Marker.Parent = markerParent
UIS.InputChanged:Connect(function()
if mouse.Target then
if mouse.Target.Parent:HasTag("Item") then
Marker.Parent = workspace
Marker.Position = mouse.Target.Parent:FindFirstChild("Handle").Position
else
Marker.Parent = nil
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if Marker.Parent == workspace then
Marker.Orientation += Vector3.new(0,0,1)
wait(.2)
end
if Marker.Parent == workspace then
if Marker.Size ~= Vector3.new(maxMarkSize)then
repeat
Marker.Size += Vector3.new(.1,.1,0)
wait(.3)
until Marker.Size == Vector3.new(maxMarkSize)
else
repeat
Marker.Size -= Vector3.new(.1,.1,0)
wait(.3)
until Marker.Size == markSize
end
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if mouse.Target then
if mouse.Target:IsA("Part") and mouse.Target.Name == "GrabBox" then
if mouse.Target.Parent:HasTag("Item") then
local item = mouse.Target.Parent
if item then
Event:FireServer(item)
end
end
end
end
end
end)