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

Why doesn't this loop?

shock = game.Lighting.Effect_Shockwave:Clone()
Knight = game.Lighting.DarkKnight:Clone()
while true do
	wait(math.random(4, 21))
	shock.Parent=game.Workspace
	shock.Position=script.Parent.Torso.Position
	Knight.Parent=game.Workspace
	script.Sound:Play()
end

I look at the output it says "15:27:55.463 - The Parent property of Effect_Shockwave is locked, current parent: NULL, new parent Workspace"

3 comments

0

Can you put a print() function between each variable declaration and after each property change?

0

Why are you using lighting to store objects? You should always use ServerStorage.

0

This is just testing

1 answer

Im not sure of exactly what the problem is, but these would be a few fixes i would recommend you trying:

only set the parent on the first run

shock = game.Lighting.Effect_Shockwave:Clone()
Knight = game.Lighting.DarkKnight:Clone()
a=0
while true do
a=a+1
    wait(math.random(4, 21))
if(a)==1 then
    shock.Parent=game.Workspace
    Knight.Parent=game.Workspace
end
    shock.Position=script.Parent.Torso.Position
    Knight.Parent=game.Workspace
    script.Sound:Play()
end

DONT use Lighting to store your items! ServerStorage and ReplicatedStorage exist specificly for storing items. ServerStorage is only visible to serverscripts while ReplicatedStorageis visible to all scripts

hope this helps a bit

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