Hello. I have this issue for 2 days, I contacted so many people but none of them could solve this problem.
Problem is, selected Gui’s position becomes {0,0},{0,0} after the tween but it’s not even an option.
This is what happens:
And this is the explorer:
(it is fine with other Gui that isn’t selected)
This was for the left button. On the right button, both of the Gui’s are being moved to {0,0},{0,0} position.
Script:
--Definitions
local OutFrame = script.Parent
local SelectedSword = game.ReplicatedStorage.Values.SelectedSwordName.SelectedSwordName0
local remote = game.ReplicatedStorage.RemoteEvents.ValueChanger
local LeftArrow = OutFrame:WaitForChild("LeftArrow")
local RightArrow = OutFrame:WaitForChild("RightArrow")
local VPFrameFolder = OutFrame:WaitForChild("ViewportFrames")
local allVPs = VPFrameFolder:GetChildren()
local tweenService = game:GetService("TweenService")
local outFramePosLeft = UDim2.new(0.01,0,0.35,0)
local outFramePosRight = UDim2.new{0.7,0,0.35,0}
local Center = UDim2.new{0.35,0,0.35,0}
--Indexes
local index = 1
local indexMin = 1
local indexMax = 2
--Tweens
local function leftSwipe(frame)
print("LeftSwipe")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local tween = tweenService:Create(frame, tweenInfo, {Position = outFramePosLeft})
tween:Play()
wait(0.6)
frame.Visible = false
end
local function rightSwipe(frame)
print("RightSwipe")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local tween = tweenService:Create(frame, tweenInfo, {Position = outFramePosRight})
tween:Play()
wait(0.6)
frame.Visible = false
end
local function toCenterSwipe(frame)
print("ToCenterSwipe")
if frame.Visible == false then frame.Visible = true end
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false)
local tween = tweenService:Create(frame, tweenInfo, {Position = Center})
tween:Play()
end
--Functions
local function indexCal(buttonname)
if type(buttonname) ~= 'string' then
assert(false, "Put a string here.")
elseif buttonname == "Right" then
index = index + 1
if index > indexMax then
index = indexMin
end
elseif buttonname == "Left" then
index = index - 1
if index < indexMin then
index = indexMax
end
end
end
local function lookForGui(index)
index = tostring(index)
for _, v in pairs(allVPs)do
local stringName = v.Name
local stringNameAll = string.split(stringName, " ")
for i, v1 in pairs (stringNameAll) do
if v1 == index then
print(v1)
remote:FireServer("SelectedSwordName0", v.Name)
return v
else
stringName = nil
stringNameAll = nil
end
end
end
print(nil)
return nil
end
local function calculatePreviousLeft(index)
if index-1 >= indexMin then return index-1 else return indexMax end
end
local function calculatePreviousRight(index)
if index+1 <= indexMax then return index+1 else return indexMin end
end
local function onRightButtonClick()
indexCal("Right")
local NextGui = lookForGui(index)
local previousGui = lookForGui(calculatePreviousLeft(index))
if previousGui then
rightSwipe(previousGui)
else
warn("Something is wrong with Gui index.")
end
if NextGui then
toCenterSwipe(NextGui)
else
warn("Something is wrong with Gui index.")
end
end
local function onLeftButtonClick()
indexCal("Left")
local NextGui = lookForGui(index)
local previousGui = lookForGui(calculatePreviousLeft(index))
if previousGui then
leftSwipe(previousGui)
else
warn("Something is wrong with Gui index.")
end
if NextGui then
toCenterSwipe(NextGui)
else
warn("Something is wrong with Gui index.")
end
end
--Events
RightArrow.MouseButton1Click:Connect(onRightButtonClick)
LeftArrow.MouseButton1Click:Connect(onLeftButtonClick)
Note:
- Indexes are correct.
- This started when I changed Gui anchor point to 0. It was 0.5 before. I replaced all values with new ones when I changed the anchor point.