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

Why doesn't the particles go on all parts at once?

I've tried making a script which allows the 'admins' to teleport to a location by saying /e apparate/location name when they say it, it's supposed to make particles go on all the players parts and then teleport but for some reason it's going to one part giving it particles teleporting then removing then going to the next part and doing the same until it has happened to all parts inside the character.. Can someone help me please?


local isAdmin = {[14946581] = true, [1] = true, [1] = true}

PC = script.Places.PotionClass.Value
TC = script.Places.TransfigClass.Value
A = script.Effect.A
B = script.Effect.B
C = script.Effect.C
D = script.Effect.D
E = A:Clone()
F = B:Clone()
G = C:Clone()
H = D:Clone()
 
 
function onChatted(message, player)
    if message:sub(1, 12):lower() == ("/e Apparate/"):lower()and isAdmin[player.UserId] then
	for _, child in pairs(player.Character:GetChildren()) do
    if child.ClassName == 'Part' then
	
	--Potion class--
	
	if message:sub(13):lower() == (PC):lower() then
	E.Parent = child
	F.Parent = child
	G.Parent = child
	H.Parent = child
	
	wait(.5)
	
	player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(PC.Location))
	wait(1)
	E:Remove()
	F:Remove()
	G:Remove()
	H:Remove()
		
		--Transfig class--
		
	elseif 	message:sub(13):lower() == (TC):lower() then
	E.Parent = child
	F.Parent = child
	G.Parent = child
	H.Parent = child
		
	wait(.5)
	
	player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(TC.Location))
	wait(1)
	E:Remove()
	F:Remove()
	G:Remove()
	H:Remove()
		
		
					
				end
			end
		end
	end
end
 
 
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

Thank you in advance.

1 answer

Try using spawn() it will run the function specified in the first argument in a seperate thread, This will help to stop it from yielding before executing on the next part

3 comments

0

I've never used 'spawn()' before.. How do I use it?

0

spawn(functionname) functionname being a function containing your code

0

Sorry but I still don't understand how to place it in my script.... Do you think you could tell me where it would go?

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