I’ve been working on this project for like 2 hours today and for some weird reason my tweens aren’t working/playing and SetPrimaryPartCFrame() doesn’t position the models at the right space at all. This is kinda disappointing since my models seemed to be doing fine until I noticed that one of my factory’s smoke was way too black and it was being doubled inside of each other.
The way my code works is that when the game is loading random structures get spawned ontop and I use tweens to make it look fancy. But tweens and setprimarypartcframe don’t work at all for some weird reason?
The weird thing its always the same model grouped up not a mix of the few and the bunch grouped up always have a glitched tween. Its not like its not playing at all it just pauses in the middle of a tween
local function AddStructure(plate, structure)
local building = structure or PixelCity.Structures[math.random(1,#PixelCity.Structures)]:Clone()
if building then
building:SetPrimaryPartCFrame(CFrame.new(Vector3.new(plate.Position.X, building:GetPrimaryPartCFrame().Position.Y, plate.Position.Z))* CFrame.Angles(0,math.rad(90*math.random(1,4)),0) )
for i,v in pairs(building:GetDescendants()) do
if v:IsA('BasePart') and v.Name ~= 'Selection' then
local cSize = v.Size
print(cSize)
v.Size = Vector3.new(0.1,0.1,0.1)
TweenService:Create(v, TweenInfo.new(1), {Size = cSize}):Play()
elseif v:IsA('PointLight') or v:IsA('Smoke') then
v.Enabled = false
delay(1,function()
v.Enabled = true
end)
end
end
print(building.Name..' built')
building.Parent = plate
end
end
I’ve tried debugging, changing the order of code. I also removed tweens and the size glitch doesnt work but the SetPrimaryPartCFrame still doesn’t work. I also thought it was because of me setting Native Vector3 to true but that didn’t seem to change anything. I’ve also used it both on the server and client plenty of times.
I might be missing something really simple but I can’t find anything
I’m not 100% understanding the gifs but I might be being stupid, are the little random parts where the factory was before you moved it not supposed to be there? Sorry, probably dumb question.
The part’s Size gets set to 0.1 on all areas and then gets tweened to its original size for a fancy “building” effect, but this shouldn’t affect any other part since I use a local variable and only tween that specific part
Basically the small parts in the gifs for no reason get paused halfway through their tween and shouldn’t even be in that position in the first place
I changed the {Size = cSize} to {v.Size = cSize} at line 10. I genuinely don’t know if it’ll fix your problem but I didn’t even know you could write it without including the object reference so give it a shot.
This example here shows setting a variable an empty table and then assigning properties to it like a dictionary. Is this what the automatic indexing is essentially doing for you (i.e assuming the word “Size” refers to the Size property), or is this another thing to maybe try? Something like:
local dict = {}
dict.Size = cSize
TweenService:Create(v, TweenInfo.new(1), dict):Play()
Sorry if this is useless, I wasn’t aware you could write that way but I hope it can help regardless.
Ok I’ve found the problem, when I set the structure’s parent to the plate, when the plate gets copied so does the structure. It can also be copied in the middle of a tween making it see weird