Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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)
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.” ABK2017 406 — 6y
0
none is not an is instance its a pairs helleric -3 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Try this instead

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

Answer this question