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

How do I un anchor the players for my TS script?

Hello, I'm making a TS (Time Stop) script and I need help. My script uses a part to function, the part gets created at the player's (who fired it) position. It expands outwards, whoever touches the part (Except the player who fired it) gets their HumanoidRootPart anchored, so they can no longer move, it also changes the lighting and other things. The script works perfectly (almost) but there is 1 problem. After the wait command I use is over, the TS script is supposed to go back to normal (Time is no longer stopped, no one frozen, lighting is back to normal) That part was fairly easy, except I have no idea how I'm supposed to un anchor the players that got affected (Or all of them in general). Thank you!

Script:

local tweenservice = game:GetService("TweenService")

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	local stopper = Instance.new("Part", workspace:FindFirstChild("Howatcha"))
	stopper.Position = workspace:FindFirstChild("Howatcha").HumanoidRootPart.Position
	stopper.Anchored = true
	stopper.CanCollide = false
	stopper.Size = Vector3.new(0.1, 0.1, 0.1)
	stopper.Shape = Enum.PartType.Ball
	stopper.Material = Enum.Material.ForceField
	stopper.BrickColor = BrickColor.new("Dark orange")
	local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true, 0)
	local goal = {}
	goal.Size = Vector3.new(918, 918, 918)
local tween =	tweenservice:Create(stopper, tweeninfo, goal)
	
	tween:Play()
	workspace.Sound:Play()
	workspace.Terrain.WaterWaveSpeed = 0
	game.Lighting.ColorCorrection.Saturation = -1
	game.Lighting.ColorCorrection.Contrast = -2
	stopper.Touched:Connect(function(hit)
		if hit.Parent.Name == "Howatcha" or "DJL7D" then
		else
			local rootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
			rootPart.Anchored = true
			wait(7)
			game.Lighting.ColorCorrection.Saturation = 0
			game.Lighting.ColorCorrection.Contrast = 0
			workspace.Terrain.WaterWaveSpeed = 10
			rootPart.Anchored = false
			stopper:Destroy()
		end
	end)
end)


1 answer

attempt or something

local tweenservice = game:GetService("TweenService")

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	local stopper = Instance.new("Part", workspace:FindFirstChild("Howatcha"))
	stopper.Position = workspace:FindFirstChild("Howatcha").HumanoidRootPart.Position
	stopper.Anchored = true
	stopper.CanCollide = false
	stopper.Size = Vector3.new(0.1, 0.1, 0.1)
	stopper.Shape = Enum.PartType.Ball
	stopper.Material = Enum.Material.ForceField
	stopper.BrickColor = BrickColor.new("Dark orange")
	local tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true, 0)
	local goal = {}
	goal.Size = Vector3.new(918, 918, 918)
	local tween =   tweenservice:Create(stopper, tweeninfo, goal)

	tween:Play()
	workspace.Sound:Play()
	workspace.Terrain.WaterWaveSpeed = 0
	game.Lighting.ColorCorrection.Saturation = -1
	game.Lighting.ColorCorrection.Contrast = -2
	local rootParts = {} -- array containing all touched rootparts
	local nohit = {
		"Howatcha",
		"DJL7D"
	} -- array to prevent the stopper part from touching unwanted players
	
	stopper.Touched:Connect(function(hit)
		local rootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
		if rootPart then
			local can = true
			for i,v in pairs(nohit) do
				if hit.Parent.Name == v then
					can = false
				end
			end
			if can == true then
				rootPart.Anchored = true
				table.insert(rootParts,rootPart)
			end
		end
	end)
	wait(7)
	game.Lighting.ColorCorrection.Saturation = 0
	game.Lighting.ColorCorrection.Contrast = 0
	workspace.Terrain.WaterWaveSpeed = 10
	stopper:Destroy()
	for i,v in pairs(rootParts) do
		v.Anchored = false
	end
end)

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