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

How do i loop this script?

wait(1)
game.Players.LocalPlayer.Character.Stun=Remove()
wait()
game.Players.LocalPlayer.Character.Stun=Remove()

Any ideas guys? also it doesnt delete the following "Stun" can some one tell me what is the right code for it?

1 comment

0

Can you add some more info. e.g what is stun and why you need this in a loop.

1 answer

✓ Accepted answer

You're using functions wrong.

To use the Remove function, you use : after the thing you want to Remove.

Don't use Remove.

Remove is deprecated, and you should be using Destroy().

wait(1)
game.Players.LocalPlayer.Character.Stun:Destroy()
wait()
game.Players.LocalPlayer.Character.Stun:Destroy()

Make sure you're using a Local Script.

Only Local Scripts can access Local Player.

-- Inside a Local Script
wait(1)
game.Players.LocalPlayer.Character.Stun:Destroy()
wait()
game.Players.LocalPlayer.Character.Stun:Destroy()

Both of these lines of code do the same thing.

If you want to continuously Destroy the Stun, use a while loop.

while wait(0.1) do
	game.Players.LocalPlayer.Character.Stun:Destroy()
end

Also, use variables,

-- Local Script in StarterPack or StarterGui
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local Stun = char:WaitForChild("Stun")-- edit

while wait(0.1) do
	Stun:Destroy()
end
This script could also be placed elsewhere , but I would suggest not doing this.
  • Side Note,

I don't like using loops, and there's probably a better way of solving your problem, but you gave no context, sorry.

Hope I helped.

Good Luck!

If I did help, don't forget to accept my answer.

1 comment

0

Edited my code to fix some errors.

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