Need help on Selecting a UI and Deselecting (Tween)

So make a sort of invisible frames for hitbox to make the selection available? but then how do i prevent the same issue?

i think there is a solution inside coding like a boolean or stuff like that, only that i don’t know how to make it

Edit: Wait i may have got it

Got the solution, I had to use mouseMoved to make it check costantly

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local UIS = game:GetService('UserInputService')

local screenGui = script.Parent
local main = screenGui.Main
local Background = main.Background
local CharacterStatsUIFolder = Background.CharacterStatsUIFolder
local ModsSelectFolder = Background.ModsSelectFolder

local MainSelectMod = ModsSelectFolder.Selection.Main

local TweenService = game:GetService("TweenService")

local data = {}
local selected = 0

for i, v:ImageLabel in MainSelectMod:GetChildren() do
	if not v:IsA("ImageLabel") then continue end
	
	data[v] = {["Pos"] = v.Position, ["Rot"] = v.Rotation, ["ZIndex"] = v.ZIndex}
	
	v.MouseMoved:Connect(function()
		if selected == 0 then
			selected = i
			TweenService:Create(v, TweenInfo.new(.5), {Position = UDim2.new(v.Position.X.Scale,0,1,0)}):Play()
			TweenService:Create(v, TweenInfo.new(.5), {Rotation = 0}):Play()
			v.ZIndex = 10
		end
	end)
	
	v.MouseLeave:Connect(function()
		if selected == i then
			selected = 0
			TweenService:Create(v, TweenInfo.new(.5), {Position = data[v]["Pos"]}):Play()
			TweenService:Create(v, TweenInfo.new(.5), {Rotation = data[v]["Rot"]}):Play()
			v.ZIndex = data[v]["ZIndex"]
		end
	end)
end

Yes, it should mitigate the issue where multiple cards can be selected simultaneously as long as the hitboxes don’t overlap. Also, it might help make it easier to play because the zones where your mouse cursor must be will be larger and static.

(edit: Well, you got it; good job. I recommend not using a dictionary for the ‘Data’ and caching the TweenObjects like in my optimized version of @fasmandom 's)

1 Like

doing the MouseMoved thing kinda helped me making the desired effect

Yeah, I was very sleepy and tired last night. I completely forgot about type checking which is a good practice, and the fact that Storing data in an Array here is completely useless… Anyways seems like the OP got it working

1 Like

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