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

How to anchor specific objects based on if they were previously anchored?

Hello everybody, this is my first post so I am sorry if the formatting is wrong.

I am trying to make a "Time Stop" script, basically it would freeze(just anchor) eveything except the player who press F and called the RemoteEvent. What I am trying to do is to anchor everything except the player, and then unanchor ONLY the objects that were previously unanchored(don't want the baseplate falling off). I am relatively new to coding so any help would be appreciated.

My code so far:

local StopTimeEvent = game:GetService("ReplicatedStorage"):WaitForChild("StopTime")
game.Lighting.TimeStopScreen.Saturation = 0
local TimeStopStartSound = game.Workspace.TimeStopStartSound
local TimeStopEndSound = game.Workspace.TimeStopEndSound

StopTimeEvent.OnServerEvent:connect(function(player)
	TimeStopStartSound:Play()
	for count = 1, 5 do
		game.Lighting.TimeStopScreen.Saturation = game.Lighting.TimeStopScreen.Saturation - 0.2
		wait (0.1)
	end
		wait(4.5)
		TimeStopEndSound:Play()
	for count = 1, 5 do
		game.Lighting.TimeStopScreen.Saturation = game.Lighting.TimeStopScreen.Saturation + 0.2
		wait(0.1)
	end
end)

Basically the player presses F on a LocalScript, which calls a RemoteEvent that makes some fancy effects using sound and color, and then would freeze everybody for 5 seconds.

1 answer

I would approach this by having a table, and when anchoring all parts except the player, make a check to see if it was anchored before you anchor it. If it was, then add it to the table. Then when you are unanchoring, check if the part is in the table. If so, don't unanchor it. I can't write any cod right now, but give that idea a try.

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