Parent Property Is Locked

ive tried using debris and tried :destroy both didnt work so please help

local tool
local template = script.Template:Clone()
local e = 0
local gpt = require(game.ReplicatedStorage.GetPlayerTag)
local invSpace = #game.Players.LocalPlayer.Backpack:GetChildren() + e
local maxInvSpace = gpt.Get(game.Players.LocalPlayer.UserId, 1)
local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
if game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") then
	e = 1
end

game.Workspace.Storage.ActivatorPart.Touched:Connect(function(hit)
	tool = hit.Parent.Parent
	if hit.Name == "Root" and script.Parent.Limit.Count.Value <= script.Parent.Limit.Value then
		local ID = Instance.new("BoolValue", game.ReplicatedStorage.Storage)
		ID.Name = tool.Name
		script.Parent.Limit.Count.Value = script.Parent.Limit.Count.Value + 1
		template.Parent = script.Parent.Frame
		template:WaitForChild("CubeName").Text = tool.Name
		template.Name = tool.Name
		tool:Destroy()
	end
end)

template.TakeBack.MouseButton1Click:Connect(function()
	local e = tool:FindFirstChildOfClass("Model")
	if e and game.ReplicatedStorage.Storage:FindFirstChild(template.Name) then
		game.ReplicatedStorage.Storage:FindFirstChild(template.Name):Destroy()
		wait(0.1)
		game.ReplicatedStorage.CreateCube:FireServer(template.Name, game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame, game.Players.LocalPlayer)
		template:Destroy()
		script.Parent.Limit.Count.Value = script.Parent.Limit.Count.Value - 1
	end
end)

If there are any errors in console screenshot them please.

image

1 Like
local tool
local e = 0
local gpt = require(game.ReplicatedStorage.GetPlayerTag)
local invSpace = #game.Players.LocalPlayer.Backpack:GetChildren() + e
local maxInvSpace = gpt.Get(game.Players.LocalPlayer.UserId, 1)
local hum = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
if game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") then
	e = 1
end

game.Workspace.Storage.ActivatorPart.Touched:Connect(function(hit)
        local template = script.Template:Clone()
	tool = hit.Parent.Parent
	if hit.Name == "Root" and script.Parent.Limit.Count.Value <= script.Parent.Limit.Value then
		local ID = Instance.new("BoolValue", game.ReplicatedStorage.Storage)
		ID.Name = tool.Name
		script.Parent.Limit.Count.Value = script.Parent.Limit.Count.Value + 1
		template.Parent = script.Parent.Frame
		template:WaitForChild("CubeName").Text = tool.Name
		template.Name = tool.Name
		tool:Destroy()
template.TakeBack.MouseButton1Click:Connect(function()
	local e = tool:FindFirstChildOfClass("Model")
	if e and game.ReplicatedStorage.Storage:FindFirstChild(template.Name) then
		game.ReplicatedStorage.Storage:FindFirstChild(template.Name):Destroy()
		wait(0.1)
		game.ReplicatedStorage.CreateCube:FireServer(template.Name, game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame, game.Players.LocalPlayer)
		template:Destroy()
		script.Parent.Limit.Count.Value = script.Parent.Limit.Count.Value - 1
	end
end)
	end
end)


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.