Part that is tweening, will not changing when value changes

Hey guys, I’m sure some of you have seen my “Reverse Ability Trouble” or some of you haven’t. It was fixed but then it rises another problem. For those who don’t know what i am trying to do:

It’s a a reverse ability where objects that are destroyed will be put back together at the press of a button.

For instance a chair, the chair is unanchored and the parts are not together, the player would click on a part of the chair, and it would be highlighted (because it has a value that allows it to be reversed) and if they hold E or something, the parts would move to form a chair (Anchored). if they release E the parts will fall back down (Un-anchored.)

now a chair is just an example, the objects would range from a bridge made of rocks to a key broken into pieces.

and what i have so far is:

local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()


local Notice = script.Selection_Notice
local NoticeCopy = Notice:Clone()

local SelNumber = 0
local Selected = {}
local SelObeject = Instance.new("ObjectValue")
SelObeject.Name = "Object"
SelObeject.Parent = script
SelObeject.Value = nil


local Tweens = {}

local CollectionService = game:GetService("CollectionService")
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local FuncMod = require(game.ReplicatedStorage.FunctionsModule)

local TI = TweenInfo.new(3,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0)

local function Check()
	for index, descendant in pairs(Selected) do
		if table.find(Selected,Mouse.Target.Name) then
			local Findindex = table.find(Selected,Mouse.Target.Name)
			
			Notice.Adornee = nil
			table.remove(Selected,Findindex)
			SelObeject.Value = nil
			SelNumber = SelNumber - 1
			Mouse.Target:SetAttribute("Selected", false)

			print(Selected)
			print(SelNumber)
		end
	end 
end

Mouse.Button1Down:Connect(function()
	if not Mouse.Target then return end
	
	if SelNumber >= 2 then return end
	
	if Mouse.Target:GetAttribute("Selected") ~= false then return end
	
	if CollectionService:HasTag(Mouse.Target, "Reversable") and Mouse.Target:GetAttribute("Selected") == false then
		Notice.Adornee = Mouse.Target
		
		SelNumber = SelNumber + 1
		SelObeject.Value = Mouse.Target
		Mouse.Target:SetAttribute("Selected", true)
		table.insert(Selected, Mouse.Target.Name)
		print(SelNumber)
		print(Selected)
		print(SelObeject.Value)
		return
	end
	if Mouse.Target:GetAttribute("Selected") == true then return end
end)

Mouse.Button2Down:Connect(function()
	Check()
	print(SelObeject.Value)
end)

repeat task.wait()
	
until SelObeject.Value ~= nil

if SelObeject.Value == nil then return false end



local OriginPos = SelObeject.Value:FindFirstChild("OriginPos").Value.Position
local OrginOrient = SelObeject.Value:FindFirstChild("OriginPos").Value.LookVector
local Move = TweenService:Create(SelObeject.Value, TI, {Position = OriginPos})
local Turn = TweenService:Create(SelObeject.Value, TI, {Orientation = OrginOrient})
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
		SelObeject.Value.Anchored = true
		Move:Play()
		Turn:Play()
	end
end)

UIS.InputEnded:Connect(function(input)
	if SelObeject.Value == nil then return false end
	if input.KeyCode == Enum.KeyCode.Q then
		SelObeject.Value.Anchored = false
		Move:Cancel()
		Turn:Cancel()
	end
end)

However i actually dont know where the problem arises in this one. the value does switch, and printing shows it. But i dont know whats happening.

Whats happening:

The error in that video is irrelevant because its easily fixable.

what i was trying to achieve is when i press and hold Q on an highlighted object it’ll slowly move back to its original position, when Q is released the highlighted part will be unanchored. when i click a different one. the old one is un-highlighted and removed from the table (in the script)

But when i click another part, it i highlighted and added to the table, however, it just doesn’t tween, and the first part that i selected does.

Once again i am not asking for full scripts, i am asking for a nudge in the right direction. Also i am hiring, i only have 10 dollars now, but Wednesday i will have around 20 or more.

DISCLAIMER, I WILL NOT PAY FIRST, THAT IS HOW SCAMS START. YOU CAN SEND ME A VIDEO OF HOW IT WORKS AND THEN ILL PAY

Thanks for reading!

1 Like