How would I fix this warning?

Screenshot (292)

2 Likes

Most likely the word is spelt incorrectly in your code.

It should read “randomize” not “randomize”

1 Like

Warning not an error. And I’m not that dumb :joy:

Literally shows in the warning that the item is spelt the same, it would error if it were spelt wrong

My bad, I jumped to conclusions do to the word being highlighted.

This warning is basically the result of an instance attempting to be patented to two other instances at once.

Or maybe the object is getting destroyed before the parenting.

Regardless of which one it is, show the full code for clarification.

(Just lines referring to “Randomise.”)

1 Like

Is that the full warning message or does it refer anything else? Perhaps your console shows a little more detail or you reference the same instance later on?

Also, I would personally discourage naming variables “Script,” I’m bound to believe it may conflict with the already existing “script” one that Lua gives us.

1 Like

That’s the only relevant code, no where else

This warning usually happens when you immediately remove the instance after it’s parent just got switched.
You could use this when destroying it:

game:GetService("Debris"):AddItem(..., 0)

(replace “…” with the instance)

Pretty certain it wouldn’t cause any conflict, it’s not named script, it’s named Script
And that’s all it says, and that’s all the relevant code.

Adding on, you could use task.wait() before changing it’s parent/removing it, if you want to do that.

It’s meant to be parented in something specific as you can see tho.

local Script = ServerStorage.Objects.NPC.Randomise:Clone()
task.wait()
Script.Parent = Plr.Character

Didn’t work

It couldn’t be destroyed before parenting otherwise it’d error. Not sure why you wouldn’t know that