Tycoon make it so only the owner can buy button (help)

Do you even ever set the “plr” value to the player’s name? I’m assuming you have a plot system that handles this…

Can we see your script again and any errors?

I think so yea. This is the script in serverscriptservice, that handles the plots.

local plrs = game:GetService("Players")
plrs.PlayerAdded:Connect(function(plr)

	for i,v in pairs(workspace.Plots:GetChildren()) do
		if v:FindFirstChild("plr").Value ~= nil then continue end
		print(v)
		v:FindFirstChild("plr").Value = plr
		v.sign.Text.SurfaceGui.TextLabel.Text = plr.Name
		local chr = plr.Character or plr.CharacterAdded:Wait()
		task.wait()
		chr.HumanoidRootPart.CFrame = v:FindFirstChild("Spawn").CFrame
		break
	end
end)

plrs.PlayerRemoving:Connect(function(plr)
	for i,v in pairs(workspace.Plots:GetChildren()) do
		if v:FindFirstChild("plr").Value == nil then continue end
		local owned_by = v:FindFirstChild("plr").Value
		if owned_by == plr then
			v:FindFirstChild("plr").Value = nil
			v.sign.Text.SurfaceGui.TextLabel.Text = "Unclaimed"
			break
		end
	end
end)

Oh, you need to change this back to the original.

Im not sure I understand, what do you mean?

Where it says if player.Name == plot.plr.Value change it to if player == plot.plr.Value .

1 Like

Done, but I get this error now:

You have “if if”, you need only one “if”.

1 Like

I’m not sure why I’m so blind to such typos, but it worked! Thank you so much! I will test in team and see if it works.

1 Like

Works like a charm, thank you!! :smiley:

1 Like