How do i make properties for multiple objects(Transparency, anchored and etc.)

yes, should work now???

This text will be blurred

1 Like

yes, good job :slight_smile:
(annoying char limit)

2 Likes

Testing it right now, thanks you guys!

1 Like

image

local Player = game.Players.LocalPlayer
local ChristmasStartedValue = Player.PlayerGui.ChristmasGUI.Frame.EventStarted
local GiftPack = game.Workspace.Gifts
local GiftN = {
	GiftPack.Gift1, GiftPack.Gift2, GiftPack.Gift3,
	GiftPack.Gift4, GiftPack.Gift5, GiftPack.Gift6,
	GiftPack.Gift7, GiftPack.Gift8, GiftPack.Gift9,
	GiftPack.Gift10, GiftPack.Gift11, GiftPack.Gift12,
	GiftPack.Gift13, GiftPack.Gift14, GiftPack.Gift15,
	GiftPack.Gift16,
}

while true do
	if ChristmasStartedValue.Value == false then
		for _, GiftNs in pairs(GiftN) do
			GiftN.Parent.Transparency = 1
			GiftN.Parent.CanCollide = false
		end
	end
	if ChristmasStartedValue.Value == true then
		for _, GiftNs in pairs(GiftN) do
			GiftNs.Parent.Transparency = 0
			GiftNs.Parent.CanCollide = true
		end
	end
	task.wait(0.5)	
end

Please try the above, Iā€™m not sure if it will work though.

2 Likes

image
ewww

Iā€™m not sure sorry, @BriefTaste made that for loop thing so they might know how to fix it, I would use a for loop but not like that.

2 Likes

Just like i need to compare a lot of lines to one line, i do not need any loop, only check one which is task.wait(0.5), i donā€™t need something else

Actually changed this to:

local Player = game.Players.LocalPlayer
local ChristmasStartedValue = Player.PlayerGui.ChristmasGUI.Frame.EventStarted
local GiftPack = game.Workspace.Gifts
local GiftN = {
	GiftPack.Gift1, GiftPack.Gift2, GiftPack.Gift3,
	GiftPack.Gift4, GiftPack.Gift5, GiftPack.Gift6,
	GiftPack.Gift7, GiftPack.Gift8, GiftPack.Gift9,
	GiftPack.Gift10, GiftPack.Gift11, GiftPack.Gift12,
	GiftPack.Gift13, GiftPack.Gift14, GiftPack.Gift15,
	GiftPack.Gift16,
}

while true do
	if ChristmasStartedValue.Value == false then
		for _, GiftNs in pairs(GiftN) do
			GiftNs.Transparency = 1
			GiftNs.CanCollide = false
		end
	end
	if ChristmasStartedValue.Value == true then
		for _, GiftNs in pairs(GiftN) do
			GiftNs.Transparency = 0
			GiftNs.CanCollide = true
		end
	end
	task.wait(0.5)	
end

You could go line by line:

GiftPack.Gift1.Transparency = 1
GiftPack.Gift2.Transparency = 1
GiftPack.Gift3.Transparency = 1

but I wouldnā€™t recommend doing that.

image
donā€™t work, gift must be invisible

Yeah i used that before, but i need ~25 gifts and this is 100 lines

show us how the Gifts look like in the Explorer > Workspace so we would know what object to change its properties

1 Like

Can you open the contents of the Gift?

1 Like

There are meshes, donā€™t think they will help somehow

I donā€™t know what to do. I have only one solution to write line by line, but when i must write ~100 lines

I donā€™t know what the problem is but try this instead. The problem could be that the gifts havenā€™t loaded in the workspace yet so it doesnā€™t change its properties.

local Player = game.Players.LocalPlayer
local ChristmasStartedValue = Player.PlayerGui.ChristmasGUI.Frame.EventStarted
local GiftPack = game.Workspace.Gifts

local function valChanged()
	if ChristmasStartedValue.Value == false then
		for i, v in pairs(GiftPack:GetChildren()) do
			v.Transparency = 1
			v.CanCollide = false
		end
	elseif ChristmasStartedValue.Value == true then
		for i, v in pairs(GiftPack:GetChildren()) do
			v.Transparency = 0
			v.CanCollide = true
		end
	end
end

ChristmasStarterValue.Changed:Connect(function()
	valChanged()
end)

valChanged()

(also i cleaned the code so it will be more efficient)

1 Like

Iā€™m need to eat, so i will test it later, thanks you a lot anyways

1 Like