Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my table going through the properties one by one?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shadow = ReplicatedStorage:WaitForChild("shadow")

local function shadowjump(player, mouse)
	local charstuff = player.Character:GetChildren()
	for i, v in pairs(charstuff) do
		if v:IsA("Part") then
			for count = 1,10 do
				v.Transparency = v.Transparency + .1
				wait(.1)
			end
		end
	end
	for i, v in pairs(charstuff) do
		if v:IsA("Part") then
			for count = 1,10 do
				v.Transparency = v.Transparency - .1
				wait(.1)
			end
		end
	end
end

shadow.OnServerEvent:Connect(shadowjump)

--	player.Character.HumanoidRootPart.CFrame = CFrame.new(mouse)

What I'm trying to do is change all the parts in the character at once to progressively turn invisible, but it goes from one part to the other in a row. Like first it does the right leg, then the right arm, then the torso, and so on and so forth. How would I go about making it all progressively turn transparent at once?

2 answers

Here's your fixed code! It's sort of hard to explain, but if you analyze it you'll probably get it!

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shadow = ReplicatedStorage:WaitForChild("shadow")

local function shadowjump(player, mouse)
	
	local charstuff = player.Character:GetChildren()
	
	for i = 1, 10 do
		for _, v in pairs(charstuff) do
			if v:IsA("BasePart") then
				v.Transparency += 0.1 -- // The same as v.Transparency = v.Transparency + 0.1
			end
		end
		wait(0.1)
	end
	
	for i = 1, 10 do
		for _, v in pairs(charstuff) do
			if v:IsA("BasePart") then
				v.Transparency -= 0.1
			end
		end
		wait(0.1)
	end
	
end

shadow.OnServerEvent:Connect(shadowjump)

It only goes 1 by 1 because you have a 'wait()' at the end of the for loop and it makes it slower.

You should only delete the waits and it will look more nicer and it will not show the effect that it's going through properties one by one(although it is).

This discussion is preserved as it was. New answers, comments, and votes are closed.