Owner StringValue is not changing on player join

My code:

local players = game:GetService("Players")
local Owner = script.Parent.Owner

players.PlayerAdded:Connect(function(player)
	if Owner.Value == nil then
		Owner.Value = player.Name
	else
	end
end)

My issue: I am trying to create an owner script for plots using a StringValue inside of the Plots folder, my issue is the value of “Owner” is not changing to the players name whenever they join the game.

Here is the structure if needed.
image

You forgot to put the Value, script.Parent.Owner.Value.

local Owner = script.Parent.Owner -- line 2

	if Owner.Value == nil then -- line 4
		Owner.Value = player.Name -- line 5

It is being called though, isn’t it?

Try to put the script in ServerScriptService and try this code.

game.Players.PlayerAdded:Connect(function(player)
for _,ownervalue in pairs(workspace.Plots:GetChildren()) do
if ownervalue.Owner.Value == “” then
ownervalue.Owner.Value = player.Name
break
end
end
end)

Thank you a lot! I appreciate it :slight_smile: