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

it dose not parent the the clone when i put it to :Destory() how do i fix?

game.ReplicatedStorage.Transfromgold.UNDOTRANS.OnServerEvent:Connect(function(plr)

local chr = plr.Character
local hum = chr.Humanoid
local waited = plr.PlayerGui:WaitForChild("er")
        for _,none in pairs(hum:GetChildren()) do
            if none:IsA("NumberValue") then
                none:Destroy()
            end
        end  ---this part wont work
                for _,kill in pairs(waited:GetChildren()) do
                    if kill:IsA("NumberValue") then
                    local copy = kill:Clone()
                        copy.Parent = workspace
                    end
                end
---
end)

the local script


local tem = "None"
local InputService = game:GetService("UserInputService")
InputService.InputBegan:Connect(function(input)


-- on 

    local key = input.KeyCode 
    if key == Enum.KeyCode.R then
	game.ReplicatedStorage.Transfromgold.Trans:FireServer()
   print("fired")
	end
end)
-----




InputService.InputBegan:Connect(function(input)
	
	local plr = game.Players.LocalPlayer
local chr = plr.Character
local hum = chr.Humanoid
    local key = input.KeyCode 
    if key == Enum.KeyCode.E then

	game.ReplicatedStorage.Transfromgold.UNDOTRANS:FireServer()
end
end)





2 comments

0

I think your Destroying the instance too soon. Destroy() “Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections and calls Destroy on all children.”

0

none is not an is instance its a pairs

1 answer

✓ Accepted answer

Try this instead

for i,v in pairs(hum:GetChildren()) do
	if v:IsA("NumberValue") then
		v:Destroy()
	end
end 

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