I am trying to make a blocking dummy for my game, with my blocking system, once the blockvalue becomes 0 the numvalue is deleted, i am trying to detect if it is deleted and clone one back into the dummys humanoid, if I could get some tips I would appreciate it
local block = game.Workspace.BlockingDummy.Humanoid:FindFirstChild("blockAction") --finds block value in dummy
local ServerStorage = game:GetService("ServerStorage")
local blockAction = ServerStorage:FindFirstChild("blockAction") -- finds the blockvalue in serverstorage for cloning in future
local Hum = game.Workspace.BlockingDummy.Humanoid
block.Changed:Connect(function()
if block == nil then
blockAction:Clone()
blockAction.Parent = Hum
end
end)
When a NumberValue is removed from something, clone the NumberValue and add it back in?
How you could do that:
Connect to the ChildRemoved event of the humanoid
Use ChildRemoved’s parameter child to reference the removed NumberValue
(Make sure to check if it’s the correct child being removed, not something else)
Clone child and parent it back to the instance
Code example:
local humanoid -- Set to Humanoid or something
local numValueName -- Set to the name of the NumberValue
humanoid.ChildRemoved:Connect(function(child)
if (child:IsA("NumberValue") and child.Name == numValueName) then
local new = child:Clone()
-- Maybe change some properties here or something
new.Parent = humanoid
end
end)
Edit:
Whoops! My bad, that should and not &&. Nice catch. I edited the code to fix that.