How can I run a system that the player owns some parts?

Well, by this I mean that how can I execute a script that only the owner of the object can use and if no one is the owner, the one who executes it is the next owner. Well, what I described I already did but it does not work for me since when it is executed, nobody owns the object so whoever executes it will not be able to get the object because nobody was the owner. the error is that I cannot execute the script because as there was no owner, there is no one who can execute it and well I want to fix that, line 17

local Storage = game:GetService("ReplicatedStorage")
local Material = Storage:FindFirstChild("Materiales")
local Recursos = Material:FindFirstChild("Cargarmateria")

local Proximity = script.Parent:FindFirstChild("ProximityPrompt")

local LumberjackSystem = workspace:FindFirstChild("LumberjackSystem")

	local PlayerWorkspace = workspace:FindFirstChild(player.Name)
	local PlayerAssets = game.Players:FindFirstChild(player.Name)
	local RightHand = PlayerWorkspace:FindFirstChild("RightHand")
	local take = PlayerWorkspace.SistemaDeTala.Taken

	local box = script.Parent
	box.Parent = PlayerWorkspace
	if player.Name == PlayerWorkspace:WaitForChild("SistemaDeTala"):WaitForChild("Owner").Value or not PlayerWorkspace:WaitForChild("SistemaDeTala"):WaitForChild("Owner").Value then
	if not box:FindFirstChild("Weld") then
		local weld ='Weld')
		weld.Parent = box
		weld.Part0 = box
		weld.Part1 = RightHand
		weld.C1 =, -0.5, 0)
	if take.Value == false then
		take.Value = true
		Proximity.ActionText = "Soltar"
		PlayerWorkspace.SistemaDeTala.Owner.Value = player.Name
	elseif take.Value == true then
			take.Value = false
			Proximity.ActionText = "Cargar"
			PlayerWorkspace.SistemaDeTala.Owner.Value = ""
			box.Parent = LumberjackSystem:WaitForChild("Wood")
			local Weld = box:FindFirstChild("Weld")
			if Weld then

From the keywords of “Object” and “own” I would presume that you could take a dab at OOP short for Object Oriented Programming. Okeansky made a video on house ownership and there’s even tutorials for it.

Okeanskys video:

Detailed info:

1 Like