Issue with time stop ability

So I’ve been trying to make a time stop ability that well stops time. It works well, it stops time and does its job but theres still one problem, it doesn’t detect scripts. So I’m trying for it to detect everything that got in the range of the attack and detect any scripts inside and disable them but it just doesn’t work D:
This is my script:

for i,v in pairs(v:GetChildren()) do
if v:IsA(“LocalScript”) then
print(“Disabled”)
end
end

I have a bunch of script behind it that defines the “v” is “v:GetChildren” and what not but when I detect a part or mesh part it works fine but not scripts for some reason so any help will make me very grateful and I hope you have a great day ;D

In your output log does it print “Disabled”?At all? if it doesn’t print it then it hasn’t found any local scripts and you want just local scripts or regular scripts aswell?

1 Like
for i,v in pairs(workspace:GetDescendants()) do
	if v:IsA("LocalScript") then
		v.Disabled = true
		print("Disabled.")
	end
end

Change workspace:GetDescendants() to whatever desired folder your script instances are descendants of.

It still doesn’t seem to work but heres my code if theres anything wrong:

local uis = game:GetService(“UserInputService”)
local tweenService = game:GetService(“TweenService”)
local camera = workspace.Camera

script.Parent.OnServerEvent:Connect(function(plr)
local part = Instance.new(“Part”)-- if the remote event has been fired
local char = plr.Character – gets the character
local root = char.HumanoidRootPart-- gets the root part
local hum = char.Humanoid
for i,v in pairs(char:GetChildren()) do
if v:IsA(“Part”) or v:IsA(“MeshPart”) then
v.Transparency = 1
print(“Invisible”)
end
end
for i,v in pairs(char:GetChildren()) do
if v:IsA(“Accessory”) or v:IsA(“Fire”) or v:IsA(“Sparkles”) then
v.Parent = game.ServerStorage
print(“Invisible”)
end
end
for i,v in pairs(char.Head:GetChildren()) do
if v:IsA(“Decal”) then
v.Parent = game.ServerStorage
print(“Invisible”)
end
end
for i,v in pairs(workspace:GetChildren()) do
if v:IsA(“Model”) and v:FindFirstChild(“Humanoid”) and v:FindFirstChild(“HumanoidRootPart”) then
if v ~= char then
if (root.Position - v.HumanoidRootPart.Position).Magnitude <= 55 then
char.Archivable = true
local clone = char:Clone()
char.Archivable = false
clone.Parent = game.ServerStorage
part.Parent = workspace
part.Anchored = true
part.CanCollide = false
part.Transparency = .5
part.Material = Enum.Material.SmoothPlastic
part.Shape = “Ball”
part.BrickColor = BrickColor.new(“Ghost grey”)
part.CFrame = root.CFrame
part.Size = Vector3.new(5,5,5)
local tweenService = game:GetService(“TweenService”)

				local tweeningInformation = TweenInfo.new(

					1, -- Length
					Enum.EasingStyle.Sine, -- Easing style	
					Enum.EasingDirection.In, -- Easing direction
					0, -- Number of times the tween will repeat
					false, -- Should the tween repeat?
					0 -- Delay between each tween	
				)

				local partProperties = {

					Size = Vector3.new(55,55,55);

				}

				local Tween = tweenService:Create(part,tweeningInformation,partProperties)
				Tween:Play()
				local eroot = v.HumanoidRootPart
				local ehum = v.Humanoid
				for i,v in pairs(v:GetChildren()) do
					if v:IsA("Part") or v:IsA("MeshPart") then
						v.Anchored = true
					end
					
					for i,v in pairs(v:GetDescendants()) do
						if v:IsA("LocalScript") or v:IsA("Script") then
							v.Disabled = true
							print("Disabled")
						end
				end
				
					for i,v in pairs(v:GetChildren()) do
						if v:IsA("Humanoid") then
							v.JumpHeight = 0
							v.WalkSpeed = 0
						end
					end
					
				end
			end
		end
	end
end

end)

Any console errors? That would help isolate the issue.

Console errors? What is a console error?

Test the game in studio and press the F9 key for the console to appear.

you trying to get the children from “v” then seeing if “v” is a local script, get the children from whatever your trying to see local scripts in

for i, v in pairs(game:GetService("StarterGui"):GetDescendants()) do
    if v:IsA("LocalScript") then
        --do things
    end
end

The thing is the workspace doesn’t actually have scripts the scripts are inside players to use like abilities and what not

ok so do

workspace:GetDescendants()

then it will get the children of everything, read more here if your still confused

I realize what you meant now, just get V and check if its a parent of the local char

Oh thank you! This is what I did but I’m not sure if its a good way and will always work

for i,v in pairs(v:GetChildren()) do
local sc = v.Parent.Parent:FindFirstChildOfClass(“LocalScript”)
if sc then
sc.Disabled = true
print(workspace.Parent)
end
end

local uis = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local camera = workspace.Camera

script.Parent.OnServerEvent:Connect(function(plr)
	local part = Instance.new("Part")-- if the remote event has been fired
	local char = plr.Character -- gets the character
	local root = char.HumanoidRootPart-- gets the root part
	local hum = char.Humanoid
	
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.Transparency = 1
			print("Invisible")
		end
	end
	
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Accessory") or v:IsA("Fire") or v:IsA("Sparkles") then
			v.Parent = game.ServerStorage
			print("Invisible")
		end
	end
	
	for i,v in pairs(char.Head:GetChildren()) do
		if v:IsA("Decal") then
			v.Parent = game.ServerStorage
			print("Invisible")
		end
	end
	
	for i,v in pairs(workspace:GetChildren()) do
		if v:IsA("Model") and v:FindFirstChild("Humanoid") and v:FindFirstChild("HumanoidRootPart") then
			if v ~= char then
				if (root.Position - v.HumanoidRootPart.Position).Magnitude <= 55 then
					char.Archivable = true
					local clone = char:Clone()
					char.Archivable = false
					clone.Parent = game.ServerStorage
					part.Parent = workspace
					part.Anchored = true
					part.CanCollide = false
					part.Transparency = .5
					part.Material = Enum.Material.SmoothPlastic
					part.Shape = "Ball"
					part.BrickColor = BrickColor.new("Ghost grey")
					part.CFrame = root.CFrame
					part.Size = Vector3.new(5,5,5)
					local tweenService = game:GetService("TweenService")
					local tweeningInformation = TweenInfo.new(
						1, -- Length
						Enum.EasingStyle.Sine, -- Easing style	
						Enum.EasingDirection.In, -- Easing direction
						0, -- Number of times the tween will repeat
						false, -- Should the tween repeat?
						0 -- Delay between each tween	
						)
					local partProperties = {Size = Vector3.new(55,55,55)}
					local Tween = tweenService:Create(part,tweeningInformation,partProperties)
					Tween:Play()
					local eroot = v.HumanoidRootPart
					local ehum = v.Humanoid
					
					for i,v in pairs(v:GetChildren()) do
						if v:IsA("Part") or v:IsA("MeshPart") then
							v.Anchored = true
						end
					end
					
					for i,v in pairs(v:GetDescendants()) do
						if v:IsA("LocalScript") or v:IsA("Script") then
							v.Disabled = true
							print("Disabled")
						end
					end
								
					for i,v in pairs(v:GetChildren()) do
						if v:IsA("Humanoid") then
							v.JumpHeight = 0
							v.WalkSpeed = 0
						end
					end
				end
			end
		end
	end
end)

The original code was poorly indented/formatted, while fixing it I noticed that one of your for loops.

				for i,v in pairs(v:GetChildren()) do
					if v:IsA("Part") or v:IsA("MeshPart") then
						v.Anchored = true
					end

This one specifically, was missing an end statement to match the do keyword. This meant that the two for loops which followed were in fact nested inside that initial for loop resulting in the entire script being dysfunctional.

Oh wow! I didn’t even notice that. I tried it again and it worked perfectly so just that little error messed up everything, thank you so much ;D

You could also left click somewhere on your screen and wait for a little side menu to pop up. Then if there is not a checkmark by “output” click it.