Instance.new not creating the new instance

yes, it does print “Workspace.identification”, but when i search “identification” in the explorer, there’s no new intvalue

the output also does not have any errors

i just used the code you gave me, but the outcome is the same. no errors are shown in the output and the intvalue still has not been created
heres all of the lines of the script up until the problem:

canbedodged = false
dodgetarget = nil
dodgetarget2 = nil
countering = false
jumping = false
parts = nil
identity = Instance.new("IntValue")
identity.Name = "identification"
identity.Parent = workspace

Make sure the instance is not being created on neither the server nor the client. Could be a replication issue.

Are you wanting to create this when the Tool is equipped? This script will run even if the tool isn’t equipped

im wanting to create this as soon as the script runs, even if the tool isnt equipped. not sure what you mean by “make sure the instance is not being created on neither the server nor the client. could be a replication issue”. it’s a server script, if that’s what you mean

Add some print statements to each step of the script or use the debugger to see if the script even runs. Chances are the script isn’t running if there’s no identity Instance

ok, just did, heres the code:

canbedodged = false
dodgetarget = nil
dodgetarget2 = nil
countering = false
jumping = false
parts = nil
identity = Instance.new("IntValue")
print("step 1, created intvalue")
identity.Name = "identification"
print("step 2, set name")
identity.Parent = workspace
print("step 3, set parent to workspace")

but still same problem, all steps are printed in output, but there’s no new instance

1 Like

Show me the workspace tree (actually look inside workspace)

ok:
{42F85B1D-C86A-47C5-AC8A-68262D3CAD3A}
is this what you mean? correct me if im wrong

1 Like

There are 4 matches yet you are only showing 3. Where’s the 4th one?

im not sure what you mean.
1st one is parented to humanoidrootpart, which is parented to the blank named rig
2nd one is parented to some npc
3rd one is parented to humanoidrootpart, which is parented to the same npc
4th one is parented to a humanoidrootpart, which is parented to the “asd” rig

1 Like

This is bizarre indeed - your function should work fine. It must be the environment or some other script interfering

any idea how to fix it? because i have no idea how to fix this. it was working fine, then i stopped development for a few weeks, and now this bug arises

It’s a bug in your studio explorer. You should be able to use the IntValue like normal within the script. Just use the identity reference to do whatever you want with the IntValue.

Try this:

local identity = Instance.new("IntValue", workspace)
identity.Name = "identification"

also show the full script, there might be an error that is happening before this part.

Check where it’s moving to before parenting it to the workspace, it’s most likely one of your scripts.

identity = Instance.new("IntValue")
identity.Name = "identification"

identity.AncestryChanged:Connect(function()
    warn("Identity was parented to:", indentity.Parent)
end)

identity.Parent = game.Workspace

Should print workspace then nil or anyother service.

Doesnt do much but hopefully if you are changing its parent to something else it makes you remember where.

If not…

Search your scripts with the “search all/find all” tab and search for workspace.ChildAdded

1 Like

this Script is working Maybe you put it somewhere wrong or you didn’t show us the rest of the Script

The only things I can think of are:

  1. A replication issue - the code runs from a client sided script(a LocalScript) and the changes don’t replicate to the server. This means that when you check if the value exists on the server(from a Script), you should not be able to find it.
  2. Another script is destroying it - another script is looking for instances added in workspace and based on some criteria it destroys or moves them from there, so you can’t find them. This script can be either an in-game one or a plugin either you or someone in your development team is using(plugins only impact studio testing most of the time).
  3. The line doesn’t run - this can be caused by many things, for example an error, an ineffective if statement, something killing the current thread before it finishes, an event not being called, etc. The quickest way to check if a line runs at all is to add a print above or below it, and check if the print appears in the output window when you expect it to.

tried this, same result though. heres the full script up until this problem:

canbedodged = false
dodgetarget = nil
dodgetarget2 = nil
countering = false
jumping = false
parts = nil
identity = Instance.new("IntValue", workspace)
identity.Name = "identification"

no errors shown in output

just tried this, output reads, “Identity was parented to: nil”