Making an item Marker

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)

1 Like

I’m pretty sure your problem lies on

And also where you tried to compare the values of 2 Vector3s as I believe that is not possible. It seems like you’re saving the maxMarkSize to be a string value; to fix this I believe you can just change it into

local maxMarkSize = Vector3.New(5.5, 5.5, 0.5)

But since you’re comparing between 2 Vectors, you can simply just make maxMarkerSize a numberValue and compare it to the X Value of the Vector3

local maxMarkSize = 5.5

-- on the if statement

if Marker.Size.X < maxMarkSize then
    -- Your script here
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.