Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i loop this script?

Asked by 8 years ago
1wait(1)
2game.Players.LocalPlayer.Character.Stun=Remove()
3wait()
4game.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?

0
Can you add some more info. e.g what is stun and why you need this in a loop. User#5423 17 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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().

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

Make sure you're using a Local Script.

Only Local Scripts can access Local Player.

1-- Inside a Local Script
2wait(1)
3game.Players.LocalPlayer.Character.Stun:Destroy()
4wait()
5game.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.

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

Also, use variables,

1-- Local Script in StarterPack or StarterGui
2local plr = game.Players.LocalPlayer
3local char = plr.Character or plr.CharacterAdded:wait()
4local Stun = char:WaitForChild("Stun")-- edit
5 
6while wait(0.1) do
7    Stun:Destroy()
8end
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.
0
Edited my code to fix some errors. User#11440 120 — 8y
Ad

Answer this question