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

Script not working after updates. anyways to update it to make it work?

here is it:

while true do workspace.stick:remove() game.Lighting.stick1:Clone().Parent = game.Workspace wait(10) workspace.stick1:remove() g game.Lighting.stick:Clone().Parent = game.Workspace

wait(10)
workspace.stick2:remove()
game.Lighting.stick3:Clone().Parent = game.Workspace
wait(10)
workspace.stick3:remove()
game.Lighting.stick4:Clone().Parent = game.Workspace
wait(10)

end

4 comments

1

Remove() is deprecated, which means don't use it anymore. Use Destroy() instead.

0

Also you're being inconsistent when referencing the game's workspace; sometimes you use workspace and other times the more verbose game.Workspace. While it doesn't affect the output of the code, consistency is always imperative for readable and non-headache-inducing code. Please change that in future projects.

0

You also should NOT be using Lighting as storage. You should be using ServerStorage or ReplicatedStorage. This isn't 2008. It makes NO sense using a service meant for handling the environmental lighting of the game, as storage.

0

what do you see in output

1 answer

Hello imagine!

I will tell you some things about your script. Firstly, remove is DEPRECATED, instead you should use destroy function. Second, you are using lighting as storage which is bad, never use Lighting for storage when you have ReplicatedStorage, ServerStorage. This script is poorly made and I will show you a way to make it work with "for i loop".

Here's a tricky way with loops :)

local Lighting = game:GetService("Lighting")
for i = 1, 3 do
	local Stick = workspace:FindFirstChild("stick"..i)
	local SecondStick = Lighting:FindFirstChild("stick"..i+1)
	if Stick and SecondStick then
		Stick:Destroy()
		SecondStick:Clone().Parent = workspace
	end
	wait(10)
end

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